/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

scipy-lectures.org/intro/
github.com/nulang/nu
en.cppreference.com/w/cpp/utility/initializer_list
stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array
twitter.com/SFWRedditVideos

First for Go.

>No anime image
>Posts POO instead

nth for go needs to go

reminder that go could have unironically been a good language but it was made intentionally shit

>dude what if we stapled the shittiest parts of java onto C

>need to learn python for a class
>found this out yesterday
>prof said there'd be tutorials for those that haven't used it before
>Be sure to go through the tutorials on this link
>click on link on assignment page
>scipy-lectures.org/intro/

how much of this do you think I can skip if I already know C++ and some scheme

The fact that OOP haters are the same people who love animu tells a lot.

/dpt/ doesn't like skippers
read the lectures lad

I read somewhere that I can choose any programming language as long as I wanted to program, and as I knew that I already had an Python interpreter installed on my Linux system, I chose Python and I am currently learning the basics. My question is that should I read a couple dozen books on Python and master this language over the years or should I learn a couple more programming languages such as C, Java, C++, Golang and Rust?

hahaha look at this faggot thinking /dpt/ is a person or some shit
hahaha what a queer

r u me?
>Getting an estimate on how much I'm going to need to pay in books for the coming semester
>Remember the last time I took Data Structures (I failed), someone in class asked the professor if we could submit our homework in Python
>Everyone in class laughed, including the professor
>Required Texts for upcoming Data Structures: "Solving Problems with Algorithms in Python" and "Data Structures and Algorithms with Python"

When jokes become reality.

...

stop learning python and learn a proper language. you don't have to completely master a language before moving on to another language because most basic programming skills will carry over to other languages.

what are you planning to do?

java, c# , golang, python are good for a variety of things

you definitely cant go wrong with java or c#

working on an anime script that'll churn out optimized lewds

First of all, I think you need to ask yourself what you want out of learning how to program. Secondly, if you were considering learning a different language at some point, focus on the language you've decided to pick up until you have a clear understanding of the basics (basic data types, flow control, loops, how functions work, and recursion). All programming languages are pretty fucking similar, the main difference being how the syntax is laid out. If you know the basics of programming, switching to a different language won't feel like shit. You'll just have to get used to the new syntax.

If you feel like what you want out of programming is Python focused, sure, go ahead and attempt to master it. If you think your interests in programming will lead you into another language, like for a certain job you looked up and would like, then after you learn the basics, consider learning that one. For example, I'm interested in graphics programming, and most graphics programming jobs use C++, so I've been making a point to learn it.

when you feel comfortable with moving on learn C with K&R and scheme with SICP
even if you never use either of those languages ever again, you'll have learned alot

Python is one of the easiest programming languages in existence, but you should still read up on it and do some basic exercises so you don't trip on any language quirks.

C is always the ideal choice for learning. Even if you don't need it practically, it gives you an idea of how programs work underneath the layers of abstraction in very high level tools. Aside from OO computers-are-magic idioms, at least.

I just realized this general doesn't have a pasta
is it because it's a particularly old general and the OP is kept clean out of tradition, or did no one ever feel like making one

>Python OOP requires you to right 'self' everywhere
I hate it, I hate it, I hate it, I hate it

it's because it doesn't need one. the topics discussed here are so broad no pasta would help cover them. this isn't a learn programming thread either, it's just one of the many things discussed here

theres a literal patel joining my team next week
what can i do to prepare?

Hashing functions.

I'm not gonna just be learning basic python+standard libraries. they need us to know python for numpy, scipy, and matplotlib. that's where the time sink emerges, learning three (to my knowledge) large and sprawling libraries

OOP is inherently horrible, so I don't blame them for not bothering to polish a turd. Python works just fine without OO.

hOw 2 maek turtel drAw fASteR!!??!?

from turtle import *
import PIL
from PIL import Image

image = PIL.Image.open("C:\\Users\\Admin\\Desktop\\c4a.jpg")
image = image.convert('RGB')


# sets up turtle window
setup(width=(image.size[0] + 50), height=(image.size[1] + 50)) # using image width to initialise window
title('Draw Image')
bgcolor('black')
colormode(255) # sets to RGB 255


# sets variables
totalPixels = image.size[0] * image.size[1]

# sets up turtle at upper left corner
speed('fastest')
penup()
goto(-1 * image.size[0] / 2, image.size[1] / 2)


pixels = list(image.getdata())

horCounter = 0
verCounter = 0
pixCounter =
pendown()
setheading(0)
hideturtle()
tracer(2000)

while verCounter < image.size[1]:
while horCounter < image.size[0]:
pencolor(pixels[pixCounter])
dot(1)
forward(1)
horCounter += 1
pixCounter += 1
verCounter += 1
horCounter = 0
penup()
goto(-1 * image.size[0] / 2, image.size[1] / 2 - verCounter)
pendown()

if nothing else a link to the online copy of the SICP would make sense seeing how much it's a meme around here

>Python
>without OO
literally everything in Python, including functions, is an object with methods and attributes

reddit tier

?

Do you need to know the libraries before class fully starts or just Python? If the latter, you will likely be able to pick it up as you go.

In an idiomatic sense.

>Do you need to know the libraries before class fully starts or just Python?
yes, and I have until Thursday

What are some ways I can profile my applications memory and cpu usage outside of an IDE like Visual Studio?

boys i need help

where can i learn c#

i tried to learn many "easy" languages before but felt that whatever tutorials i tried did not help me to understand any of the abstractions behind the language itself

what the fuck is all those brackets, man?

>
First code box is wrong because you could be doing free(NULL).
Rest seems alright but if you don't copypaste everything into your main, you are going to have a spaghetti of errors dispersed along different functions. A million if checks everywhere. Say fn2 can return -1, -2, -3, -4, depending on where it failed, and fn1, which uses fn2, can return -1, -2, -3, -4, and then -5, -6, -7 which are other places of failure.
With throw/catch you just put a try in the main, and you catch whatever gets tossed up from anywhere, with allows you to debug with ease.

intel has a bunch of tools for that sort of thing if you're willing to pay some shekels

I guess you could just watch it under htop and see

thoughts on nulang?

github.com/nulang/nu

contributors look like nu-males

Drop Python immediately. Read book in your pic.

>doesn't implement any standardized lisp
I bet it doesn't even support reader macros, and at that point you can't even call it a lisp.

*-edition threads are the best threads.
See: /brit/

>reinventing lisp for webtards

use common lisp or clojure if you have a brain

>Obj-C runtime
Dropped harder than trump's approval ratings

I've been lazily working on implementing Learntris in OCaml. I'm a full time C++ programmer and a long-time hobbyist Lisper, but I heard that OCaml was pretty neat.

I'm a simple man
I see OCaml
I laugh

How many of these do you have?

Fuck StackOverflow anyway

>Going to Cuckoverflow
>Current era

Employed Haskell programmer reporting in

>implying employed as haskell programmer

...

Since SO isn't being very helpful, I'll see if I can explain the problem...

In C++, where the auto keyword is not used for a function parameter, it means "use the default type of whatever is on the right of this expression". Any list of elements between braces is of type std::initializer_list. Though there is an automatic conversion from an initializer_list to an array, this is only done when the typename is explicit. Since arr is an initializer_list, there isn't a [] operator defined on it. Really, check the documentation:

en.cppreference.com/w/cpp/utility/initializer_list

Now print_array and sort are just template functions under some nice syntactic sugar (that's how auto as a parameter works). When you pass in arr, it tries to substitute the type of auto for std::initializer_list, and then runs into trouble when trying to call the [] operator.

The solution is to explicitly declare arr as an std::array or std::vector, since you need both a size() method and operator [] method.

Also, your sort method looks wrong. Step through it and see what happens when you pass it an already sorted list.

>your sort method looks wrong.
same sorting algorithm
stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array

Hey, back again still trying to solve this seemingly simple problem with extrememely limited programming skills. To recap.
On Ubuntu
Have a text file, animals.txt that contains:
rat
dog
dog
rat
rat
dog
cat
cat


the bash script someone wrote, which should take every unique item, and list them next to the percentage of total items they appear, also, (and not in this code) I'd like what that % is of a number that can be stored in a variable.
So took me a while to realise "sh calc.sh" didnt work so ran "bash calc.sh"

this is the code:
#!/bin/bash
total=$(wc -l < animals.txt)
words=$(sort --unique < animals.txt)

for word in $words; do
count=$(cat list | grep -F "$word" | wc -l)
percent=$(bc

oh wait I see your point

Graduate from bash

Read the damn messages.
>cat: list: No such file or directory
"list" does not exist.

What esoteric programming language is this?

What is a program?

A magic spell used to make the computer do something.

Like bags full of sand.

ok, the fact it's called "list" makes it pretty hard to know what to do, as a complete noob that I admit I am.

Why is SICP so fucking god-tier? I have had so much fun tackling each of the exercises so far since they can be challenging but ultimately simple once you approach the problem correctly, and I have so far learned so many things my shitty college refused to teach me, and this is all only by chapter 1 so far. This book is like a treasure.

And yet it has 0 relevance in the real world.

You've literally fallen for Sup Forums's feminine penis.

Don't use magic numbers in your code.
Eg store it in a variable (here, file) and then use it.
list was probably the original name, but you renamed it or something.
#!/bin/bash
file=$1
total=$(wc -l < $file)
words=$(sort --unique < $file)

for word in $words; do
count=$(cat $file | grep -c "$word")
percent=$(bc

kek

Anyone know why this matlab block of code isn't working?

num_files = 4

file_arr = zeros(1, num_files)
for ind = 1:num_files
str = strcat(folder_path_str, 'Image', int2str(ind), '_Temperature.csv')
file_arr(ind) = str
end

Thank you so much

nothing, what should i work on

an SDL2 library for Rust that isn't complete ass
post here when you're done (hopefully in less than an hour) because I need one for a project I'm working on and don't give enough of a fuck to write it myself when I can just abandon the project and do something else.

You could write your project in C. Come back home prodigal user.

You want a port in Rust? Why?

but i've already done that a hundred times user. I wanted to try something new. But community support in rust is pretty bad...

To interface with rust code. I just need a wrapper really.

(((structs)))

The C# Expando Object lets me create members at run time. Is there a way to import these members into the current namespace without the instance identifier?

Will book in OP image help me to be more confident in social situations?

>working
>after hours

yeah nah how about I shitpost instead.

I'm learning Go right now and it is super /comfy/. I have the flexibility of a scripting language with the speed of a compiled one. No bloat too! Why don't you program in the super /comfy/ Go?

Enough with the language discussions.
What this thread should really be about is how we raise consumer expectations so they start demanding good software so pajeet and women(female) can't take over this field.

Software in general sucks ass right now. It's slow, buggy, insecure and lacking in functionality. It should be better. I don't think it's developers faults but rather the work environment that demands crappy solutions because the end-user doesn't care. So we need to manufacture demand.

See

>Software in general sucks ass right now.
>raise consumer expectations
The consumers don't care. The consumers can never care. Bad software is the fault of the programmer's delusions.
>It should be better.
make it so

>2018 - 1/3
>not writing everything in Lua + C

>using lua
>ever

how do i into embeddeds

First step is to stop using shitlangs that don't help you catch mistakes

MUH TYPS

GUYS, GUYS TYPES

TTYYPPEESS

DUDE TYPES LMAO

So in my C program i use djb2 hash function, but the function itself, as most other hash functions do, doesn't account for collisions, so i guess that's left to the developer. I'm using an array, so i think i will need to implement some sort of linear/quadratic probing or even double hashing. What's the fastest, simplest and most portable way of solving collisions?

you upset?

exactly

Create buckets instead.

>client insists that we target the JVM
Why the fuck do they care what a standalone system runs on?

Lies, he can post on HN bragging how awesome it is.

they reverse engineer the java bytecode easier.

(You)
I forgot to mention, i'm hashing ASCII strings and my array is 1024 elements long. How should i adapt djb2's outcome (unsigned long) to my needs? Modulo? Last/first 10 bits?

(You)
Sorry, but i must use closed hashing

Like it will even help them, you have to write truly awful Java code to get good performance out of it.

DUDE TYPES LMAO

in java how come you can alter arrays from within other methods, but you cant alter ints

for example


public static void combine(ArrayList listOne, ArrayList listTwo){


listOne.addAll(listTwo);
}


would actually alter whatever array listOne was in the method it was called in, but if you did that with ints like below it wouldnt


public static void main(String[] args) {
int number = 1;
addThree(number);
System.out.println(number);
}

public static addThree(int number) {
number = number + 3;
}

it doesn't seem you're returning the number in the addthree function. Or am I misunderstanding how java works?

I forgot to mention, i'm hashing ASCII strings and my array is 1024 elements long. How should i adapt djb2's outcome (unsigned long) to my needs? Modulo? Last/first 10 bits?

Sorry, but i must use closed hashing

i'm not returning it, which is what im getting at

if you put an arraylist in your parameter you can fuck with that arraylist and itll actually be still fucked with if you check it out after calling the method. if you do the same with an int like in the addThree method, it doesnt affect the parameter that you inserted outside of that method