[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 41
File: anime.png (201 KB, 335x365) Image search: [Google]
anime.png
201 KB, 335x365
Previous Thread: >>55425257


What are you working on, /g/?
>>
File: 1354310326949.jpg (9 KB, 320x180) Image search: [Google]
1354310326949.jpg
9 KB, 320x180
>>55430983
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.
>>
>>55431084
Thanks for actually posting a good anime this time OP.
That trap meme needs to die
>>
File: 1467754418255.jpg (31 KB, 446x389) Image search: [Google]
1467754418255.jpg
31 KB, 446x389
What's the best programming language and why is it FORTRAN?

>>55431139
The previous OP wasn't a trap, it was simply a flat chested tomboy, says MISAKA.
>>
5th for Hasklel
>>
7th for C#
>>
File: five_cute_facts_about_maki.png (143 KB, 336x430) Image search: [Google]
five_cute_facts_about_maki.png
143 KB, 336x430
hello /g/, 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 /g/'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?
>>
>>55431200
>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?
>>
>>55431209
Before anyone says something stupid: Python
>>
>>55431209
Whatever you fucking pick don't pick Python or Java

Jesus fucking Christ don't do it
>>
>>55431209
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?
>>
>>55431264
>>55431243
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
>>
>>55431209
C, I'm not even kidding. You could move to any language you want after learning it with no difficulties.
>>
>>55431289
C# is ok. Much better than Java.
>>
>>55430025
>all written in python
No
They all USE python. They are not BASED in python.
There is an enormous difference.
>>
>>55431332
C is pretty good too

>>55431284
Readability
>>
>>55431232
>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.

>>55431289
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
>>
>>55431284
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++)
>>
File: 1430696109223.jpg (93 KB, 720x720) Image search: [Google]
1430696109223.jpg
93 KB, 720x720
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.
>>
>>55427459
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.
>>
>>55431449
The Linux Command Line: A Complete Introduction is a very good book and the recommended introduction.
>>
>>55431449
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 \
>>
>>55431501
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.
>>
File: KE6QNYVh.jpg (177 KB, 1024x967) Image search: [Google]
KE6QNYVh.jpg
177 KB, 1024x967
>>55431583
>>
File: Capture.jpg (21 KB, 577x266) Image search: [Google]
Capture.jpg
21 KB, 577x266
What does she mean by VB scripts? I know VBA. Is that the same shit?
>>
>>55431615
I swear this is one of the things google has actively made harder to find results for
>>
>>55431178
This is a really cute girl.
>>
>>55431590
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.
>>
>>55431641
>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
>>
>>55431641
What does the A stand for?
>>
>>55431670
Fuck that I could make quite a bit from this.

>>55431674
Visual Basic for Applications.
>>
File: 1373777183170.gif (1 MB, 720x405) Image search: [Google]
1373777183170.gif
1 MB, 720x405
>>55431514
I was hoping for something shorter, like 20 pages.

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

>>55431655
magical index
>>
>>55431722
dumb shinoposter
>>
File: holo2.jpg (16 KB, 360x360) Image search: [Google]
holo2.jpg
16 KB, 360x360
>>55431284
For loops are just syntactic sugar for a while loop, so the question that you should ask is why people use loops at all
>>
File: 1374941846596.gif (2 MB, 720x405) Image search: [Google]
1374941846596.gif
2 MB, 720x405
>>55431735
Alice. Not Shino.
>>
Writing a 3D cheese pizza MMORPG in WebGL
>>
>>55431514

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
>>
>>55431801
>>>/g/wdg/
>>
>>55431777
loops are just syntactic sugar for recursion.
>>
File: tuck me in blanket.jpg (76 KB, 495x636) Image search: [Google]
tuck me in blanket.jpg
76 KB, 495x636
>>55431084
>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?
>>
>>55431814
Nah
>>
>>55431881
surely infinite loops co-recur
>>
File: galko.png (824 KB, 700x682) Image search: [Google]
galko.png
824 KB, 700x682
>>55431881
Nope since loops exists in the same stackframe, recursion with tail call optimization overwrites the current stackframe desu
>>
>>55431935
holy shit you are dumb
>>
>>55431935
Loops aren't about stack frames.
>>
>>55431935
>implementation details
>>
>>55431200
Your index starts at 1, python arrays are 0 indexed, start at 0.
>>
Anyone have any high level info on learning sockets?
>>
>>55431209
I'd suggest either C or Scheme and learn with SICP.
>>
>>55431962
Are you calling me stupid
>>
>>55431209
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.
>>
>>55431641
>>55431674
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

>>55431777
>>55431881
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.
>>
>>55432225
>this being different from a plain loop since each instance of the function call has its own local variables and so on. Whereas
Wrong
>>
>>55431881
recursion is just syntactic sugar for the beta reduction of the Y combinator with whatever function you need to execute multiple times
>>
>>55432225
>when there's a repeat of the "function call" mechanism
no

>>55432238
mostly this
>>
Can queues be implemented with generators?
>>
File: 1467576444649.jpg (74 KB, 1000x488) Image search: [Google]
1467576444649.jpg
74 KB, 1000x488
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?
>>
>>55431215
no one?
>>
>>55432329
Number theory.
Combinatorics and cryptanalysis.
>>
>>55432329
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
>>
>>55432329
just make sure when anyone says "random" you correct them and make sure they understand its pseudo-random.

Fuck.
>>
>>55432329
type theory
formal proofs
type systems
>>
>>55431501
Isn't "IO" just another name for a procedure?
>>
>>55432329
Manifolds
>>
>>55432536
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
>>
File: monad diagram.png (26 KB, 334x358) Image search: [Google]
monad diagram.png
26 KB, 334x358
>>55432555
*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
>>
>>55432555
>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.
>>
>>55432599
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
>>
>>55432632
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
>>
File: 1381722046322.png (70 KB, 300x300) Image search: [Google]
1381722046322.png
70 KB, 300x300
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"
>>
>>55431641
>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
>>
>>55432754
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)
>>
>>55432754
>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
>>
>>55432754
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.
>>
>>55432781
where did you learn this?
book or website recommendation please.
>>
>>55432846
i didn't learn it from a book or website
>>
>>55431655
Pedophile
>>
>>55432856
well that explains everything then.
I'l just have to try and make sense of the official documentation.
>>
>>55432754
maybe they assume someone in the field of programming is not so retarded as to not understand what's going on here + disregard rtfm
>>
>>55432881
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?
>>
>>55432754
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
>>
File: Screenshot_2016-07-05_16-43-09.png (30 KB, 506x1037) Image search: [Google]
Screenshot_2016-07-05_16-43-09.png
30 KB, 506x1037
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
>>
File: 1465284119566.jpg (139 KB, 535x498) Image search: [Google]
1465284119566.jpg
139 KB, 535x498
how many of you here have written your own compiler and how many are just script kiddies copying code from stack overflow?
>>
>>55432948

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

arr[0](1)
>>
>>55432948
if you're asking whether C++ can have an array of functions then the answer's no i think
>>
>>55433053
*IntToVoid arr[]

>>55433056
C++ can have an array of functions, so can C
>>
>>55433041
another question: how many of you are "elite" college kids, and how many of you actually produce anything of value?
>>
>>55433056
That is what I'm asking. Sorry for not being clear.

>>55433069
Thanks. I found an answer on stack overflow
>>
>>55433041
Both :3
>>
File: IMG-20160704-WA0003.jpg (43 KB, 381x339) Image search: [Google]
IMG-20160704-WA0003.jpg
43 KB, 381x339
>>55431200
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?
>>
>>55433246
fucking retard proprietaryfag
>>
>>55433246
they're the windows executable file type. Gnu Make for example can make them
>>
>>55432083

bump for this question, heading to bed soon so i'll leave it at this
>>
>>55433281
A socket is pretty much a file.
The end.
>>
>>55433281
what do you mean "high level"?

read beej's guide to network programming and report back with questions
>>
File: MerchantRoll.webm (245 KB, 500x500) Image search: [Google]
MerchantRoll.webm
245 KB, 500x500
>>55431084
from heritage import tricks

for goy in goyim:
if tricks.trick(goy):
tricks.extract(goy["shekels"])
if goy["shekels"] == 0:
print("oy vey!")
else:
print("good goy!")
else:
tricks.shut_it_down(goy, 6000000)
>>
>>55433270
>Gnu Make for example can make them
You are stupid
>>
>>55433307
I basically had no where to start reading - I will go with Beej's guide.

Cheers, Anon.
>>
>>55433314
>lame joke
>lame language
>lame code

It all checks out
You're definitely from reddit
>>
>>55433317
if i was stupid would i be getting fresh pussy on a daily basis?
>>
File: 1455967972225.jpg (9 KB, 250x247) Image search: [Google]
1455967972225.jpg
9 KB, 250x247
>>55433246
>> Calculator
>>JS OR PHP +HTML/CSS
>>
>>55433343
Happens often to dumb people.
>>
any good books or resources on Microservices? Work is going to be pushing for this buzzword in a few months, I figure we'll end up with status quo but it can't hurt to be prepared.
>>
>>55433264
That's not an answer...
>>
>>55433338
>jew jokes
>>from reddit
in what world does that happen?
>>
File: 1466577279086.png (71 KB, 780x530) Image search: [Google]
1466577279086.png
71 KB, 780x530
>>55433456
>>55433489
Unless of course, you're an irritated python programmer?
>>
File: memes.jpg (46 KB, 695x431) Image search: [Google]
memes.jpg
46 KB, 695x431
>>55433506
Pic related is literally telling people to avoid using loops in Python

Avoiding Python is literally Python's style guide
>>
>>55432911
anyone? not this poster, but I'm interested, too. should I just go and ask >>>/sci/ ?
>>
File: Screenshot_2016-07-05_18-28-57.png (30 KB, 917x1037) Image search: [Google]
Screenshot_2016-07-05_18-28-57.png
30 KB, 917x1037
>>55433053
>>55433056
>>55433069
Thanks bros
>>
File: 1466300211816.jpg (134 KB, 1920x1080) Image search: [Google]
1466300211816.jpg
134 KB, 1920x1080
>>55433664
you're welcome

maybe one day you could X-MACRO the pinMode bit
>>
>>55433573
Some people turn every bool returning function into a return true else throw
It's cancer
>>
>>55433689
>It's cancer
That's Python for you
>>
>>55432329
Functional programming.
>>
rust is a hell of a lang

send help
>>
>>55433041
I want to write my own compiler but I'm too dumb for it.
I've written a VM + assembler + linker before though.
And FUCK linkers.
>>
File: wario.png (7 KB, 384x224) Image search: [Google]
wario.png
7 KB, 384x224
Quick, /g/! Write a function that prints the lyrics to the name game given a name as an argument!

Theme music:
https://www.youtube.com/watch?v=fihc2ONQ5v0

What's the name game?
https://en.wikipedia.org/wiki/The_Name_Game

Bonus goals:
- fewest bytes possible
- esoteric programming language

Get on it!
>>
>>55433041
I've never written a compiler and I program for a living
>>
>>55433343
Yes, you would be.
>>
>>55433759
>Quick /g/, do my homework!
>>
>>55433041
I've wrote a Lisp interpreter in Python, and copy pasted code from Stackoverflow to cut arbitrary deadlines.
>>
In C++ I'm reading 5 bytes from a file, and instead of making a temporary buffer, then putting each component into the correct variable (which are all declared as part of a struct), I just have it read in starting from the address of the first member of the struct.

It works fine and all the variables are receiving the correct values, but will this assumption always hold? Is it reasonable to think a given compiler will allocate the memory for struct members of the same size contiguously and without padding? I want the best performance and memory usage possible at any given instant, but I'd rather have reliability and portability / resilience to future changes and compiler bugs.
>>
>>55433801
endianness could fuck shit up if you aren't considering that
>>
>>55433801

>but will this assumption always hold? Is it reasonable to think a given compiler will allocate the memory for struct members of the same size contiguously and without padding?
Yes
>>
What's the simplest way for a client to send messages to a daemon?
dbus? sockets? something else?
>>
>>55433827
The files it'll be reading are stored big endian, but each chunk is only one byte. So no possibility of needing to swap byte order, unless some architecture I don't know about reverses the order of the bits and that matters somehow. Shouldn't though.

>>55433830
Okay. I guess I'll put a comment in the case I don't remember.
>>
>>55431200
DELET THIS
>>
>>55433859
http rest ;)
>>
>>55433880
~delete yourself~
>>
>>55433887
I'm not talking about a web server and client you retard.

I have a daemon, I want to be able to send messages to it to make it do things and receive the output, sockets are overkill for this.
Should I use dbus?
>>
>>55433923
wtf retard, just run a local http server and use that
>>
>>55433759
void ng(char* n){
char* m = n++;
printf("%s, %s, bo-b%s,\nBanana-fana fo-f%s\nFee-fy-mo-m%s\n%s!\n",m,m,n,n,n,m);
}
>>
File: 1425313095730.jpg (62 KB, 300x489) Image search: [Google]
1425313095730.jpg
62 KB, 300x489
Suggest to me a small to medium sized project to undertake in a language specified by you, the poster.
>>
>>55433981
Scientific calculator, Befunge. Chop chop.
>>
File: fit container td.jpg (351 KB, 1681x958) Image search: [Google]
fit container td.jpg
351 KB, 1681x958
How do I make <td>'s have variable heights depending on the contents of the td or atleast cut off td's of certain sizes?

I'm a little stumped
>>
>>55433996
>Befunge
Jesus, this is worse than Brainfuck.
Also looks more fun though.
>>
>>55432937
>are you confused by how this is done by the interpreter or something?
No I know how it's done. I'm confused as to why it's done.
In C you have:

for ( init; condition; increment ) {
statement(s);
}


here you just have

for ( init; condition;) {
statement(s) /n;
}


Wheres the increment control? WHY is it just incrementing by 1?
How does it know how to safely stop looping at the end of the array?
Why is it adding a line break after printing every increment?

These are the kind of questions I expect to have explained in a tutorial for new users.
>>
>>55433923
>sockets are overkill for this
no they're not
>>
>>55433996
Too difficult. Suggest another.

>>55434006
>>>/g/wdg
>>
>>55434014
It's not worse, I find befunge quite fun actually. Especially the BeQunge IDE that implements the befunge-98 specification that allows you to program in 3+ dimensions and supports multi-threading.
>>
>>55433940
I sincerely hope you're just baiting.
>>
>>55434056
>Wheres the increment control? WHY is it just incrementing by 1?
Nothing is incremented, you just get the next element of the array.
>>
>>55433981

Nes emulator in Elixir.
>>
>>55434056
>In C you have:
no you don't, there's nothing enforcing initialization, the condition, or incrementing to be present at all.
for (;;) {}
for (puts("Hi"); 1 + 2; puts("memes"));

are valid for loops. a foreach loop doesnt have much to do with incrementing and shit.
>>
>>55434078
>you just get the next element of the array.
print(my_list[0]);
1 /n
print(my_list[1]);
2 /n
...

The array is clearly being incremented and a new line character is being slapped on at the end because there clearly was not one in the array. Does print automatically add a new line character?

Why is this so poorly documented???
>>
>>55434056
You're confused about pointers
That's normal for newbies don't sweat it
>>
File: asd.jpg (18 KB, 400x247) Image search: [Google]
asd.jpg
18 KB, 400x247
What motivates you to keep going?
>>
>>55434132
>The array is clearly being incremented
What the fuck are you talking about? No.
>>
>>55434151
memes
>>
>>55434151

Constant playlist of songs with subliminal messages inserted.
>>
>>55434056
>These are the kind of questions I expect to have explained in a tutorial for new users
The whole point of python is not having to deal with that stuff.

>How does it know how to safely stop looping at the end of the array?
It probably uses a length property.

>Why is it adding a line break after printing every increment?
That's just what the function does. I think puts in C does this as well.

>Wheres the increment control? WHY is it just incrementing by 1?
It's going through each ELEMENT in the array which it in putting into the variable i for you to do things with.
>>
>>55434128
Yes. But that's not whats happening in this example.
y_list = [1,2,3,4]

for i in my_list:
print(i)


for (i,my_list){
print(i);};
}


would not print
1
2
3
4
>>
>>55434151
Drugs. My will and stubborness was compromised years ago, as were all the mental tools I developed to perform low level architectural work on my personality and control my mindset. Self delusion by design is self destruction.

So I fill the gaps with stimulants and sedatives. Kava mixed with cocoa beans is the best. Works okay if core ideals and desires are intact.
>>
>>55434190

Hate to tell you but

y_list = [1,2,3,4]

for i in y_list:
print(i)


Does output
1
2
3
4
>>
>>55434228
That's why i'm confused. In python (the top example) it does. In C (the bottom example) it does not. And no python tutorial adequately explains why.

>>55434176
>Wheres the increment control? WHY is it just incrementing by 1?
>It's going through each ELEMENT in the array which it in putting into the variable i for you to do things with.

That's what I thought, but I wish I could get that from a tutorial and not my guesses.
>>
>>55434228

The c++ equivalent to this would be

vector<int> y_list = { 1,2,3,4 };
for (auto i : y_list) {
cout << i << endl;
}
>>
>>55432754
>C fag here.
I doubt you've written more than 100 lines of C asking dumb shit like that
>>
>>55434288

Technically python isn't incrementing at all. It's actually using a iterator method to traverse the object.
>>
File: 1456385556346.jpg (3 MB, 3739x5031) Image search: [Google]
1456385556346.jpg
3 MB, 3739x5031
How come you still can't do fizzbuzz, /dpt/?
>>
>>55434302
Asking for a tutorial/book recommendation = programming noob. I think you misunderstood what I was asking.
>>
>>55434132
>The array is clearly being incremented
python does that internally for you. that's what makes python... python. actually, many languages support similar features.
>>
>>55434322

It has been well proven that dpt can fizzbuzz..

void FizzBuzz(size_t Num) 
{
char* messages[4] = { "%i\n", "Fizz\n", "Buzz\n", "FizzBuzz\n" };
for (size_t i = 1; i <= Num; i++) {
printf(messages[(!(i % 3)) + 2 * (!(i % 5))], i);
}
}
>>
>>55432754
It's implicit how it works. Even batch works this way.

for /l %%N in (0,1,15) do echo %%N

WOW, it outputs the numbers one line at a time. It's almost like every echo statement breaks after its execution. Like how does it even know man... why would it do that...

Come on anon. Supposedly you write programs.
>>
>>55434302
>>55434353
Actually fair enough. I was so focused on complaining about all the crap I kept running into I did not make it clear enough that I was looking for tutorial recommendations and not asking how for loops worked.
>>
>>55433981
"Goodbye World" program in Malbolge
>>
>>55434288
We explained to you many times.

>>55434302
This
>>
>>55434151
Interesting projects. But once I get a working proof-of-concept the heat dies down and I don't work on it unless it is something I will use often.

Would I make a good researcher?
>>
>>55431935
>loops
>recursion

you just went full retard son
>>
>>55434420
this
>>55434376
I would delete it if I could.

Let's start fresh.
Heres what I should have originally posted.

Can anyone recommend a good python book/tutorial for someone who already knows c/c++?
>>
>>55434376
this is why you don't learn C as a first language, unless you have a good teacher to respond to your questions.
it's very difficult to learn C for non technically-minded
>>
>>55434132
>Why is this so poorly documented???
https://docs.python.org/2/tutorial/controlflow.html#for-statements

Literally perfect explanation in the official docs. I think you'd do better to ask
>Why am I so shit at looking for documentation???
>>
>>55434464
I don't feel and it feels great. I sold my atlas to buy new brakes.
>>
>>55434350

Just for fun

template<typename ty, typename f>
static inline result_of_t<f(ty,ty)> range_map(ty x, ty y, f func)
{
auto result = x;
while (x <= y) {
result = func(result, x++);
}
return result;
}


void MapFun()
{
string messages[4] = { "%i\n"s, "Fizz\n"s, "Buzz\n"s, "FizzBuzz\n"s };

auto const FBuzz = [&](auto x, auto y) {
printf(messages[(!(y % 3)) + 2 * (!(y % 5))].c_str(), y);
return 0;
};

range_map(1, 101, FBuzz);

}


Made this a while back to start exploring some of the new c++ features.
>>
7zip multi password extractor

it will try every password from a list on each archive. successful ones get put in complete folder.

requires that 7zip is setup in environment variables.

import subprocess
import glob, os
from tkinter import *
import shutil

def execute(target,password_list):
processfolder = "%s%s" % (target,'\\[Complete]')

#check if our completion folder exists.
if not os.path.exists(processfolder):
os.makedirs(processfolder)
else:
print ('folder exists, skipping')

with open(password_list, 'r') as f:
passwords = f.readlines()

os.chdir(target)

for file in glob.glob("*.rar"):
for i in passwords:
print("Archive: "+file)
print ("Trying with Password:"+ i)
dirname = file.replace(".rar","")
output = subprocess.Popen('7z x '+ file + ' -o' + dirname + ' -p' + i,stdout=subprocess.PIPE).communicate()
if 'Everything is Ok' in str(output):
print ('========SUCCESS==========')
shutil.move(file,processfolder)
break

def key(event):
target = e1.get()
os.chdir(target)
passes = e2.get()
execute(target,passes)

def window():
global e2
global e1
root = Tk()
root.title("7z Multi Pass Extractor")
Label(root, text="Target Folder:").grid(row=0)
Label(root, text="Password List:").grid(row=1)

root.bind("<Key-Return>", key)

e1 = Entry(root)
e1.insert(END, '')
e2 = Entry(root)
e2.insert(END, '')

e1.grid(row=0, column=1)
e2.grid(row=1, column=1)

root.mainloop()

window()
>>
>>55434464
This one >>55431084

>or are for outdated versions of python
doubt that
>>
Why is web Dev so shit? I can get a opengl app going in like 5 minutes and people say graphics programming is "hard", yet I spend a whole day solving dependency issues and setting up libraries, client/server side, etc when webdeving.
>>
>>55434531
>setting up environment having anything to do with programming
>hard

stop
>>
>>55434531
The people who say graphics programming is hard are not web devvers. Go into /wdg/ and ask who has experience in graphics programming, and every single one of them will reply. WebGL has brought graphics expertise to webdev.
>>
>>55434488
you have a very strange definition of "fun"
>>
>>55434506
Meant to say >>55432754
>>
>>55434554
Most webdevs I know suck at maths. They must be doing stupid/basic shit.
>>
>>55434558

What is wrong with it?
>>
>>55434550
Not my fault webdev is the most inconsistent/disorganized shit. Specially nodejs, godlord.
>>
>>55434666
Someone link an article about one guy pulling his tiny obscure practically 3 line javascript project from a centralized library company's server, and it breaking thousands of projects, some of them quite high profile.

It just proves these long dependency trees are a mess and stupid by their very nature. Collectivism needs to be kept in check, always.
>>
>>55434709
Never mind, found it.
http://qz.com/646467/how-one-programmer-broke-the-internet-by-deleting-a-tiny-piece-of-code/
>>
>>55434709
how would you solve dependency hell for web dev though?
>>
>>55434743
In a personal sense, by not having a project structure that allows external dependencies. I would recursively update local copies of any of the dependencies.

In a wider sense, I don't know. You can't stop people from embracing this sort of structure, and it does have merits. The company mentioned in the article I linked tried to reconcile some of these issues, but as I said, a higher capacity for problems is in its very nature and it necessitates a constant degree of faith. People who don't like that faith obviously won't operate that way, but regardless its existence clearly has wider implications than the experience of a single individual.

Guess like everything else, the human species will just have to keep cyclically fucking up until it learns to live with itself.
>>
>>55434743

You really don't it's a problem that is on the vendor's end and the consumer's end. It's best to just use the least amount of external dependencies that you can get away with.

Updating a dependencie generally means breaking something.
>>
>>55434743
Ban JavaScript.
>>
>>55434944

Js backends aren't the only ones that suffer from dependency hell. It's bad in python / ruby shops too
>>
>>55435007
ban dynamic-typed scripting languages

use semantic versioning
>>
>>55434944
I'm working on a site right now which is strictly html and css; supports browsers with javascript disabled on principle.
I can understand why JS is smeared around websites like shit along the walls of a public bathroom. Some visuals are just so much simpler with it and things like the <template> tag are useless without it.
>>
>>55435058

Semantic versioning just tells you if the upgrade makes api breaking changes, extra backwards compatible extra features, or bug fixes.

It doesn't stop the fact that eventually you're going to have to work with the breaking changes eventually (Security fixes, better performance, etc).

Dynamic typed languages aren't causing the problem either. I've ran into dependency hell in plenty of C code bases while installing / maintaining linux utilities.
>>
>>55435138
No programming then. You need to invent general AI and have it output machine code directly.
>>
>>55435157

We're getting better with ai. But I seriously don't believe we'll advance that far until we start hitting the limitations of silicon and need to move towards quantum computers. Even then it's going to a be hellish transition (A bit can be on and off at the same time in quantum computers).
>>
>>55433664
Shouldn't this give an error since the steps array only has 8 elements?
i is going from 0 to 512.
>>
>>55435213

It won't give a error this is at the bare metal level. The code will just try to perform a function call with whatever random data is stored in memory past the 8 valid elements. Literally there is no telling what it will do.
>>
>>55435513
Won't the OS throw a segmentation fault if detects an attempt to access an address not allocated to the application?
>>
>>55435539

There is no os here. Bare metal == Literally running at the cpu level with nothing below your code protecting you.
>>
>>55435558
Oh. I didn't read back to see the context.
>>
>>55435539
Technically, the CPU would throw the segfault.
>>
>>55435585

Does it matter if you've got nothing setup to handle the cpu exceptions?
>>
>>55435585
Is the memory controller typically an aspect of the hardware, and separate from the OS?
>>
what's a good, up to date software engineering book? i still feel like i don't know what the fuck i'm doing and what should be done even when i'm getting good results from programming
>>
>>55431084
Making my website, so far so good.
>>
File: Flonne.full.1795985.jpg (795 KB, 1168x1665) Image search: [Google]
Flonne.full.1795985.jpg
795 KB, 1168x1665
>>55431084
Has any /g/entleman worked with WPF? I need some resources of MVVM pattern, I have checked some tutorials but only tells how to change a page programatically.
>>
File: output.webm (2 MB, 480x640) Image search: [Google]
output.webm
2 MB, 480x640
it works!
http://pastebin.com/tiaWjXr8
>>
>>55435957
>http://pastebin.com/tiaWjXr8

So what are you planning on using this for?
>>
>>55436001
i don't know yet really. i'm mostly playing around. i want to build a 3D printer one day, but i currently don't have the hardware or skills to do it.
>>
>>55432160
why would it be easier to jump to haskell or prolog after learning C versus other languages
>>
>>55433756
compilers are easy as fuck

first write a program that takes a lambda calculus expression and interprets it (basically, just lisp symbols, lambdas, and function application)

then modify that program to generate "compiled" functions that take an environment and do the actions prescribed by the program.
(this idea is covered in `Section 4.1.7 Separating Syntactic Analysis from Execution` of SICP)

Then write another program that generates C or assembly code that does the same thing.
>>
File: 1453686234461.jpg (18 KB, 251x242) Image search: [Google]
1453686234461.jpg
18 KB, 251x242
>>55431200
>return
>>
>mfw python and django
>>
>>55433761
why not, read sicp (I know you haven't because you haven't written a compiler) and learn how.
>>
>>55431200

You know, if you're just iterating over an entire array, rather than a subset of it, you don't even need to index it. Just do something like this:

def cuteFactsAboutMaki(facts):
print(len(facts), " cute facts about Maki:")
for fact in facts:
print(" -", fact)

facts = ["She's a slut!", "She's a girl!", "She's a tomato!", "I love her!!!!!", "Maki!!!!!!!!!!!"]
cuteFactsAboutMaki(facts)
>>
>>55436345
he's just memeing because of the pic which only has 4 pics you absolute melt
>>
>>55436357
>4 pics
4 points
>>
>>55431200
>maki
>a slut
fuck off
>>
>>55434322
>Fizzbuzz
Am I missing something or is this fucking easy?
How the fuck can someone's have problems with that.
>>
File: fizzbuzz of the christ.png (402 KB, 1024x768) Image search: [Google]
fizzbuzz of the christ.png
402 KB, 1024x768
>>55436456
but is your fizzbuzz jesus-approved?
>>
File: wordsearch.png (78 KB, 581x604) Image search: [Google]
wordsearch.png
78 KB, 581x604
Word search game in JS + HTML.
>>
>>55436499
nice, how do you select words?
>>
Onsite interview on friday. Wish me luck. If I get it, that means we can all make it.
>>
>>55436603
Good luck m8, I hope this (or next) month I'll start going to interviews.
>>
>>55431449
Install arch.

I'm not even memeing, installing arch will teach you how to use the CL pretty well.
>>
>>55436648
Thanks! Are you doing any sort of prep?
So far I've gotten most of my questions, or variations of, from leetcode dot com
>>
>>55434464
https://docs.python.org/3/tutorial/index.html

Coming from C, this should be darn straightforward. It was for me at least.
>>
>>55436531
By clicking on the first and last letters of each word.
>>
>>55434478
> Non-technically minded
Why even bother programming?
>>
>>55436661
>Are you doing any sort of prep?
I'm a hobbyst programmer, because didn't finish college I'm in a hurry to get a job.
>>
>>55434464
http://www.greenteapress.com/thinkpython/html
>>
>>55436754
Best of luck! Prep well!
>>
File: ZkehhiS.jpg (31 KB, 800x800) Image search: [Google]
ZkehhiS.jpg
31 KB, 800x800
How meticulously do you guys plan your code when it's for a side project? Do you try to calculate the runtime before you actually start writing it?
>>
>>55436801
I don't.
http://www.martinfowler.com/articles/designDead.html
>>
>>55436801
never prematurely optimize

TDD is best driven-development
>>
>>55436793
ty, I think the site that you linked it's going to be helpfull, going to check it tomorrow.
>>
>>55436828
As long as you focus on actual important tests. Many unit tests contribute to nothing: you want tests that can fail, not 90% coverage. It's a slippery road.
>>
>>55436801
I do minimal planning and improvise as I go along. It's much more fun that way. In professional software development, you've to do a lot of planning and rigorous testing, which is very boring.
>>
>>55436847
I agree that most units contribute nothing, but you should try to reach maximum coverage anyway because it means all your branches work as expected. I was working on adding tests to a colleague's code yesterday, and I thought I had a lot of tests, but in the end they were all necessary to force the code branching to perform correctly.
>>
>>55436801
>yfw this is how poltards learn politics
people are so fucking retarded
>>
>>55431243
Python's a great first language. Teaches you proper formatting and isn't forcibly OO like C# or Java in style, and its easy to read for anyone.
>>
Is there anywhere I can contribute to something or even make money writing python?
Tried those freelance sites, most of that stuff is either really specific, even if I do bid on something I've never gotten it.
I'm getting pretty good at it but what's the point of all I'm doing is writing unless shit that I'm going to use personally...?
>>
>>55436926
You could always get an office job and write programs to your work for you.
>>
>>55436878
>reach maximum coverage anyway because it means all your branches work as expected
Having this assumption is incorrect. Covering is a stupid metric since it has no meaning to checking expected behavior. It's use cases which need to be covered. This distinction is most of the time not done and leads to great waste of time. I'm not saying that's what you're doing, but that special emphasis should be made.
>>
>>55436926
I make money writing python as my job uses python+django

inb4 webdev, it's surprisingly fun
>>
>>55436847
honestly, one of the bigger advantages of always unit testing your shit is that it forces you to write reusable (and by extension USUALLY better) code
not to mention that its very helpful when you need to make a bunch of changes without having a good idea of the side effects

but yeah, unit tests rarely catch any bugs in my experience, its more of a contract that proves your shit works the way the specification says it should
INTEGRATION testing on the other hand has caught a ridiculous amount of bugs
>>
>>55436926
get a web backend job (django) or somekind of math job (cant remember exactly what is is, but python is popular there)
>but webdev is for codemonkeys
its the exact same shit, but with a web ui instead of a desktop one
>>
>>55436951
I can agree that it covers use cases over expected behavior, but covering all use cases is a necessary part of a whole test suite, surely?
>>
this creates an archive(.cbz) of all sub-directories 1 level deep.

ie;
folder1
--> sub_01,sub_02 = sub_01.cbz, sub_02.bz

@echo off

for /d %%r in ("%cd%\*") do (
for /d %%f in ("%%r\*") do (
7z a -bsp0 -tzip -mx0 -mmt=off "%%~fr\%%~nxf.cbz" "%%~fr\%%~nxf\*" -y -wy:\TMP | FIND ".cbz"
)
)
Thread replies: 255
Thread images: 41

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.