/dpt/ - Daily Programming Thread

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

Negotiate.
You have a lot of leverage if you are the most productive one there. Just make sure your efforts are known while doing it.

If that doesn't work, and you really want to work less for them, use the extra time to brand yourself really well online using your own projects or contributing to OSS. Then, using this impressive version of yourself, find a job that will be better than your current one.

After doing that, negotiate with an ultimatum: Ask for something that is better than the other place you found, or threaten to leave.

No matter how they answer, you win.

killing niggers

Thanks for actually posting a good anime this time OP.
That trap meme needs to die

with your programming?

What's the best programming language and why is it FORTRAN?

The previous OP wasn't a trap, it was simply a flat chested tomboy, says MISAKA.

5th for Hasklel

7th for C#

hello Sup Forums, there seems to be something wrong with my code
I am new to programming, and as a short little project to start out, i wanted to write a program that lists 5 cute facts about Sup Forums's waifu, maki

def cuteFactsAbout(Maki):
print(len(Maki), "cute facts about Maki:")
for factNum in range(1, len(Maki)):
print(" -", Maki[factNum])
return
maki = ["She's a slut!", "She's a girl!", "She's a tomato!", "I love her!!!!!", "Maki!!!!!!!!!!!"]
cuteFactsAbout(maki)

it only seems to list 4 facts though, what went wrong?

What is the best programming language to learn first?

>1-indexed arrays

> TL;DR How do I sanitize and run uploaded python code? Perhaps a sandbox?


Wrote an rest API that controls arbitrary restful API's. It can pload handlers for each endpoint and configure them. Only problem is sanitization. As the handlers are run without restriction I have a Single POF if someone uploads malicious code. How do I sanitize it?

Before anyone says something stupid: Python

Whatever you fucking pick don't pick Python or Java

Jesus fucking Christ don't do it

Even fucking Visual Basic would be better, or fucking Pascal or logo or Excel Formulas

Anything but Python or Java
They will ruin you for life

why do people use while loops?

what about c#
:^)))
no but seriously I'm not him but I just started learning c# as my first language and so far it's going smooth
but I know it's pretty similar to Java and that's off limits

C, I'm not even kidding. You could move to any language you want after learning it with no difficulties.

C# is ok. Much better than Java.

>all written in python
No
They all USE python. They are not BASED in python.
There is an enormous difference.

C is pretty good too

Readability

>Whitespace as syntax
>Originally used runtime hacks to make it OOP
>Encourages syntax and habits that do not translate over to any other language
Python is garbage for anybody but people who don't need to program on a regular basis, like researchers or mathematicians who need basic scripts.

C# is like Java++. It's way cleaner and offers a lot, and visual studio is a godsend of an IDE.
That being said, C or C++ is a better "starting" choice because less will be abstracted away from you.

Learning on C# is kind of bad because you can just say var for everything and the CRE figures it out

Sometimes it makes more syntaxical sense to say
while(thing remains true (or negated untrue))
than it does to say
for(int i = 0; i < someArbitraryCounter; i++)

So my new workplace uses all linux pcs (Centos). I don't want to look like a putz. Is there a book that teaches you stuff you're supposed to type into the terminal? I want to look like I know what I'm doing.

The point isn't to have no side-effects. The point is to maintain referential transparency, which basically means if you define "x = some expression", you can always replace "x" with "some expression" without changing the meaning of a program. Here is an example of something that is not referentially transparent:
random :: () -> Rational
random () = -- Some magical routine that produces randoms

foo :: Rational
foo = let x = random () in x / x
-- Not the same as
bar :: Rational
bar = random () / random ()


Filling in the definition of "x" gives a different meaning to the program, because random does not preserve referential transparency. "foo" is guaranteed to be 1, but "bar" could be any number of values, depending on what "random" can generate. Thus you won't see a function like this in Haskell. Notably, IO DOES respect referential transparency:
randomIO :: IO Rational
randomIO = ...

-- liftA2 f ma mb is the program that runs ma, runs mb, then applies f to the results
liftA2 :: (a -> b -> c) -> IO a -> IO b -> IO c
liftA2 = ...

-- Run x twice and apply division over the results
foo :: IO Rational
foo = let x = randomIO in liftA2 (/) x x

-- Run randomIO twice and apply division over them
bar :: IO Rational
bar = liftA2 (/) randomIO randomIO

(We have to use liftA2 because the division operator only operates on (certain kinds of) numbers, and not on programs)
Here foo runs x twice and applies / over it, and bar runs randomIO twice and applies / over it. But foo and bar are the same program, since running x is the same as running randomIO by definition.

The Linux Command Line: A Complete Introduction is a very good book and the recommended introduction.

I can't for the life of me find that fucking image of that woman with a linux computer typing in

ld
ld...
ld
cd ..
cd .
ld \

Why is referential transparency something you should want? Being able to replace expressions with their definitions (this includes the result of a function application like "f 2", since its "definition" is the result), anywhere makes it a lot easier to refactor, and you have to worry less about mutable state invading everything. I say "less" because you can still get some of the same issues reasoning about mutable state, if you use abstractions that simulate state, or if you are using IO things, which represent impure programs. But if you have a function that takes a function as input, you are guaranteed that applying the function will never change the behavior of the program elsewhere, and that applying it to the same arguments will always give the same results.

Referential transparency is also particularly important in Haskell due to its nonstrict (read: lazy) evaluation semantics. It's important that the evaluation of an expression never produces side-effects, because it's hard to tell when things will get evaluated, if at all, with lazy evaluation.

...

What does she mean by VB scripts? I know VBA. Is that the same shit?

I swear this is one of the things google has actively made harder to find results for

This is a really cute girl.

Also it's important to note that the IO type is only a *representation* of impure programs. If you enumerated the IO operations you were allowed to do, you could hypothetically define IO as an expression tree, which gets broken down and evaluated at run time. In practice, real impure code is used to represent IO, because it's more efficient and allows the implementation to expose a C FFI.

>not dropping them for using 2 question marks at the end of a sentence instead of 1 question mark at the end of a sentence

What does the A stand for?

Fuck that I could make quite a bit from this.

Visual Basic for Applications.

I was hoping for something shorter, like 20 pages.

Thanks anyways.

I wish the IO monad in Haskell was just what was described the other week - a value describing an impure program

magical index

dumb shinoposter

For loops are just syntactic sugar for a while loop, so the question that you should ask is why people use loops at all

Alice. Not Shino.

Writing a 3D cheese pizza MMORPG in WebGL

Not him, but thanks. Going to install some kind of Linux distro on a dual boot sometime this week to get back into using it, will work through this along the way

...

loops are just syntactic sugar for recursion.

>tfw ywn cum inside Windows 10-tan

>Have a range of callgrind and cachegrind profile logs saved out for a variety of compiler flag combinations and source edits
>boss asks me to add ms time output to source so he can see where the time is going
>tell him where the time is going and offer my profile logs so he can open in kcachegrind or some other visualizer
>insists on before/after ms time output for each source file and for each query (but is adamant on not using `explain analyze` on the queries to see why they're slow)
Has anybody written a program to kill me yet?

Nah

surely infinite loops co-recur

Nope since loops exists in the same stackframe, recursion with tail call optimization overwrites the current stackframe desu

holy shit you are dumb

Loops aren't about stack frames.

>implementation details

Your index starts at 1, python arrays are 0 indexed, start at 0.

Anyone have any high level info on learning sockets?

I'd suggest either C or Scheme and learn with SICP.

Are you calling me stupid

I started with C. A lot of people started with C.
Start with C and you'll be able to jump to other languages with ease.

VBA = Visual Basic for Applications, included with MS Office for automating tasks and stuffs
VBScript = Windows scripting language based on Visual Basic
VB.Net = .NET infrastructure version of Visual Basic

Strictly speaking, "recursion" in computer science terms only occurs when there's a repeat of the "function call" mechanism, this being different from a plain loop since each instance of the function call has its own local variables and so on. Whereas loops are implemented as conditional gotos.

>this being different from a plain loop since each instance of the function call has its own local variables and so on. Whereas
Wrong

recursion is just syntactic sugar for the beta reduction of the Y combinator with whatever function you need to execute multiple times

>when there's a repeat of the "function call" mechanism
no

mostly this

Can queues be implemented with generators?

Rewriting code to download and analyze media files.

What I had written should never have worked, and yet it had for the last few weeks. Last night it finally fucked itself, filled the servers SSD with thousands of temporary files, and crashed it.

I want to be the ultimate obnoxious holier-than-thou cunt possible. Here's my list of subjects I'm studying to achieve this goal:

Category theory
Lambda calculus
Formal languages

What else can I study to be the definitive computer science prick?

no one?

Number theory.
Combinatorics and cryptanalysis.

Abstract algebra, but you really shouldn't confuse people talking about things you don't understand for 'being obnoxious'

It seems you've already achieved your goal, after all

just make sure when anyone says "random" you correct them and make sure they understand its pseudo-random.

Fuck.

type theory
formal proofs
type systems

Isn't "IO" just another name for a procedure?

Manifolds

No, IO is a type, specifically it's a monad (it's a higher kinded type, like a template from C++ or a generic type)

I suppose you could say functions that return IO values are sort of procedures

*i phrased it badly but a monad is sort of like a specific interface, all monads are higher kinded (taking one type parameter) but most higher kindeds aren't monads

>No, IO is a type, specifically it's a monad
"Procedure" is also a type that obeys the monad laws.

>I suppose you could say functions that return IO values are sort of procedures
Functions that return procedures are functions. The IO values themselves are procedures.

They ostensibly might not be procedures in some obscure case and I wouldn't assume they're all procedures, but certainly in most cases they are

This might not be considered a counter example but system calls and FFI for instance might be thought of as not "procedures", but both are IO

C fag here.
How does anyone learn python?
All the tutorials iv found hardly explain anything or are for outdated versions of python.
1 example I found that keeps appearing:
my_list = [1,2,3,4]

for i in my_list:
print(i)

prints
1
2
3
4

but they never explain why it just knows to increment by 1 without any instructions, or put a line break after printing each increment. I would have guessed the output to only be 1, and not print the entire array.

It's always "ok that's it, now you know how loops work"

>2 question marks in a work email
i'm a born again virgin but i think this means she wants to suck you off right

for, in this case, runs the code in the block (i.e. the bit after the : that has tabs before it) multiple times, once for each item in my_list, substituting i for an element each time

so
for i in my_list:
print(i)

is sort of like
i = my_list[0]; print(i)
i = my_list[1]; print(i)
i = my_list[2]; print(i)
i = my_list[3]; print(i)

>but they never explain why it just knows to increment by 1 without any instructions, or put a line break after printing each increment.
because python is shit

If you want to get technical the array object has an iterator(probably) and the for in iterates over that returning each item per step. Objective-c has object enumerators and stuff at least. i is something in my_list.

where did you learn this?
book or website recommendation please.

i didn't learn it from a book or website

Pedophile

well that explains everything then.
I'l just have to try and make sense of the official documentation.

maybe they assume someone in the field of programming is not so retarded as to not understand what's going on here + disregard rtfm

here's your (you)

How could I manage to understand gradient descent building only upon high school mathematics? What do I have to learn before?

is english not your first language? are you confused by how this is done by the interpreter or something?
I'm not a native english speaker, yet I clearly see how "for i in my_list" means "for each i element in this list, do the following" or something along the line

Does anyone know if it's possible to put a function in an array and call the function by just calling the element of that array.
I'm working with a stepper motor and the way it works is you have to turn the magnets on and off in a specific order to get the motor to turn.

If I want to specify how many degrees to turn it, I have to specify how many steps to turn it which means calling on the step#() functions individually and possibly not running through all 8 steps.
One way I've seen to do this is to use a switch with 8 cases corresponding to each step, but switches are ugly.

I want to know if I can put each function in an array (or structs and pointers) and then loop over the elements in the array a certain number of times instead.

The language is c++ i think

how many of you here have written your own compiler and how many are just script kiddies copying code from stack overflow?

typedef void*(int) IntToVoid;
IntToVoid[] arr = { step1, step2, step3 };

arr[0](1)

if you're asking whether C++ can have an array of functions then the answer's no i think

*IntToVoid arr[]

C++ can have an array of functions, so can C

another question: how many of you are "elite" college kids, and how many of you actually produce anything of value?

That is what I'm asking. Sorry for not being clear.

Thanks. I found an answer on stack overflow

Both :3

You started programming. Well if you can btfo NEETdom why not

Can someone explain something to me? I'm kind of new to programming and am confused.

When I compile a program and run it, both in Java and Python, I have to run it from the command line or a built in IDE.

Yet when I run a program written by someone else, like foobar2k, it opens from a desktop icon. How do I make my programs like that?

And let's say I want to put a calculator on a website or something, how would I go about doing that? What language would I use?