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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 33

File: 1474324749075.png (154KB, 299x291px) Image search: [Google]
1474324749075.png
154KB, 299x291px
old thread: >>56763328
>be me
>make fresh github for a portfolio
>git clone some small projects from some open sores cucks
>change license and all copyright text to my name
>reupload as my own repo
>make beautiful github homepage featuring "my" projects
>watch the recruiter emails pour in
>receive job offer after just 2 interviews
>some open sores cuck noticed I stole his code
>threatens to get the FSF involved (LMAO)
>send github a DMCA takedown notice on their repo, claiming they relicensed my code
>they actually believe me
>never hear from him again

Thanks for the FREE SOFTWARE, freecucks!

Keep putting everything online for people to steal, the GPL won't do shit about some guy stealing your project unless you have hundreds of thousands of users.
>>
First for Python.
>>
You forgot to fork() the last thread
>>
>>56769519
>Thanks for the FREE SOFTWARE, freecucks!

Communism is never okay.
>>
High, been going through some Project Euler questions with Python 3.

I was wondering if this was a thing with the language recently in that the sum() function is slower than a regular loop. I've noticed it on a few previous problems.

"""
Problem 56 - Powerful digit sum
https://projecteuler.net/problem=56
"""
import time

def mainComp():
return max({ comp(a**b) for a in range(1, 100) for b in range(1, 100)})

def mainLoop():
return max({ loop(a**b) for a in range(1, 100) for b in range(1, 100)})

def comp(n):
return sum((int(i) for i in str(n)))

def loop(n):
total = 0
for i in str(n):
total += int(i)
return total

def timeD(func):

def wrapper(*arg):
t = time.time()
res = func(*arg)
print(func.__name__, time.time()-t)
return res

return wrapper

if __name__ == '__main__':
c = timeD(mainComp)
print(c())
l = timeD(mainLoop)
print(l())]


This is what I get weirdly. I have some more examples if need be.
mainComp 0.34107041358947754
972
mainLoop 0.2940559387207031
972
>>
>>56769519
First for Java
>>
File: 1468483545166.jpg (68KB, 1039x638px) Image search: [Google]
1468483545166.jpg
68KB, 1039x638px
>imperative programming
for what purpose?
>>
java > the rest

you literally CANNOT disprove this statement
>>
>>56769744
i like to feel in control
>>
>>56769790
if that's control, i'd hate to see out of control
>>
>>56769795
i agree, so you'd better give me respect. half of me is the nicest trap you'll ever meet. and the other half? well...
>>
>>56769744

Stop posting this functionalturd.
>>
File: 1467434345362.jpg (63KB, 500x281px) Image search: [Google]
1467434345362.jpg
63KB, 500x281px
>>56769880
>the only alternative to imperative programming is functional programming
>>
>>56769896

Yes, that's correct.
>>
How can I stop vim ignoring my indent settings when editing python files?
>>
>>56770024
by doing 2 spaces instead of tabs
>>
>>56770024
don't use vim
>>
>>56769744
Getting stuff done rather than mentally masturbating all day.
>>
use emacs
>>
>>56770091
*tips*
>>
https://www.infoq.com/presentations/Taming-Effect-Simon-Peyton-Jones
>>
>>56770024
I know there's a way to make vim use different configs for files with different extensions. I haven't looked into this deeply enough to tell you how to do it, but I do know it's possible. Google around anon, I'm sure you'll figure it out :).
>>
>>56770068

Haskellfags can't handle the truth
>>
>>56770024
>vim
>python
A crude, simplistic editor for a crude, simplistic "language." Good riddance.
>>
>>56770024
Put stuff in
~/.vim/ftplugin/python.vim
.

>>56770237
>vim
>simplistic
Vim has many problems, but simplicity isn't one of them.
>>
>>56770259
i don't think simplicity can be construed as a problem. you could argue it sometimes causes other problems, but it's never in itself a problem, only a benefit
>>
>>56770320
I know. I was both denying his statement that vim is simplistic and pointing out that one of vim's problems is complexity.
>>
>>56770046
pls explain
>>
>>56769643
Could be that your caches are warmed up. Reverse the order of operations in which you do comp and loop and see if you still get the same result.
>>
>>56770560
> caches
> having any effect on python performance
kek
its not called forced flushing of cache for nothing
>>
>>56770259
simplistic doesn't mean simple

it means downplaying complicated issues as if they were simple, which is exactly what python does

i dont know enough about vim to say one way or the other
>>
File: erfdftgjkil.jpg (66KB, 1287x721px) Image search: [Google]
erfdftgjkil.jpg
66KB, 1287x721px
I'm the anon who earlier asked if rendering 50 sprites individually would hurt performance.

After trying it, I can render 1,000,000 without any drop in fps, and 10,000,000 at 5fps
>>
File: DensitySlider.gif (2MB, 449x385px) Image search: [Google]
DensitySlider.gif
2MB, 449x385px
Is it possible to over-engineer solutions in CS classes?

For example, making a program very safe by adding handlers for all possible inputs, as long as it isn't at the expense of performance or anything alright even if it inflates the code size?


Also, unrelated, but I've made quite a bit of progress on my density grapher.
>>
File: poopy.gif (736KB, 588x442px) Image search: [Google]
poopy.gif
736KB, 588x442px
Wow, it's magic!
>>
>>56770807
Make a webm of it for scientific purposes.
>>
File: win98screensaver.gif (950KB, 588x442px) Image search: [Google]
win98screensaver.gif
950KB, 588x442px
I'm so glad I'm finally getting to realize my dream of writing Windows 98 screensavers.
>>
>>56771190
that doesn't look very random for some reason
>>
>>56771190
>>56771288
Write something with boids
>>
>>56771163
Yup, mostly because they expect people to do the bare minimum. I don't think over-engineering is bad. It's a good exercise for the programmer.
>>
>>56771360

The boid algorithms look fairly simple, but I already shut down the VM.

Maybe I'll get around to it another time when I'm procrastinating from my coursework.
>>
>>56771412
https://www.youtube.com/watch?v=M028vafB0l8
>>
>>56771435

Neat.
>>
>>56771410
will I likely be marked down for it?

My plan was to make some a standardized package that I could import with all the basic handlers for edge cases that were likely to appear so I don't have to fuck with it later
>>
So how do you get work as a programmer really?
>>
>>56771540
Pray 3 times a day
>>
>>56771467
AS long as it's readable, I don't think you should. Do you have a rubric?
>>
>>56771567
emphasis unintended
>>
>>56771567
Yeah, but all it mentions is the class's definition of cheating and student expectations etc
I'll probably just ask the professor, but he's legendarily hard to get ahold of
>>
>>56771585
I'm pretty sure you're fine as long as you don't make your functions long enough where it's hard to read. I myself have been trying to apply things from Code Complete in my assignments.
>>
File: sphericalDensity.gif (2MB, 591x554px) Image search: [Google]
sphericalDensity.gif
2MB, 591x554px
>>56771635
I've not read that but

as an example, my current assignment is to make a piece of software that manages internationals at the school- It handles their Visas, what they're allowed to do, and it prevents them from attempting to break the limits of their Visas in the database.

The thing is, this is an intro java course and I'm not exactly sure what the professor expects. One could look at this assignment (given the level of the class) and produce anything from an incredibly simple borderline-hardcoded-from-input "database" that would demo what we've learned in class in a simple way, or you could take what we've learned to produce a fullblown database manager. He's mentioned the packages we'd need to do so and gone into slight detail of them, but he didn't imply that we had to use them or anything.


TLDR: I hope I'm making sense, but it's not clear if we're expected to produce very simple toy programs or if we're supposed to produce software that actually works well.
>>
What's it called when you're allowed to only write part of the constructor, and unset variables bounce to default?

I.E. if I have a class RegularPolygon that I'm trying to instantiate that has the constructors (int sides, float size, Color color), if I were to just call RegularPolygon(sides) it'd have size = 1 and Color = white, their defaults.
>>
>>56771890
Default parameters.
>>
i'm a cs sophomore working professionally as a programmer and have a few cool personal projects on my resume. i just applied for summer internships at big 5 companies, do i have a chance? i've yet to meet anyone in my program that knows wtf they're doing but i'm not god-tier either. is it actually super hard to get into google or will i be okay /g/?
>>
>>56771711
>>56771163
did you post this in FP WAYWO? hehe
>>
>>56771957
No, but the person I'm working with might have.
>>
>>56771549
I'll do that
>>
>>56771711
A lot of professors in academia have a hardon for giving intentionally vague assignments as a way to prepare you for a code-monkey job, where those are basically exactly what you're going to be given.
Do something that meets any requirements set by the assignment and use your best judgement as to what you should or shouldn't bother adding. Keep in mind it's an intro course and most of the people doing this assignment couldn't program their way out of a paper bag, so if something you're thinking of seems like too much to expect out of that kind of person, you probably aren't meant to do it.
>>
>>56771984
well I mean
he asks for some stuff that we wouldn't be able to do unless we knew about some more """""""advanced""""""""" (massive fucking quotations around that, I'm talking about in terms of the class) functions of Java. For instance, the Date package that we learned about doesn't do time between two dates, but we're expected to produce that for this project.
>>
>>56771942
Having both work experience and personal projects will most likely get your foot in the door, so it really comes down to how well you do in the interviews.

I got hired by Google towards the beginning of last year and personally I was a little surprised by how easy the interviews were. Don't get me wrong, it was still challenging, but I'd been expecting something crazy difficult.

I'd recommend studying interview questions if you want to maximise your chances, and also so you know what to expect.
>>
>>56772137
thanks for the info. i picked up CTCI today and am going to power through it while i wait for a call back. i haven't taken data structures & algorithms yet but i'm at least vaguely familiar with most general CS concepts so i'm hoping i can make it with a little studying.
>>
>>56771984

My professors often dedicate a portion of class time for questions about the assignments. When they don't, or when that time is insufficient, I meet with them during their office hours to clear up any ambiguities in their assignment description. A smart professor is less vague in their assignment description, as being more vague will only lead to more students asking questions like "how should this program behave in <some corner case>?"
>>
File: rmsgoiy.webm (3MB, 720x480px) Image search: [Google]
rmsgoiy.webm
3MB, 720x480px
>>56769519
top kek

open sore cucks are so easy to exploite it's great.
>>
>>56772167
Good luck anon.
>>
>>56772195
Try this with Linux. Those cucks will fill every hole on your body.
>>
Pulling a Form out of some Elm Add/Update Pages into a separate Module.
>>
>>56772208
>being afraid of neet basement dwellers

top cuck m8
>>
trying to learn coroutines so i wrote a simple implementation of them in c.

its neato, but since it doesnt pass values around its pretty useless so far.

n3985 was the most helpful thing to read, most articles on coroutines seem lacking.
void fn(coro this, void* _other) {
coro_ptr other = _other;
log("%d : entering then yield back to calling\n", this > other);
coro_yield(this);
log("%d : yielding to %d\n", this > other, other > this);
coro_yield_to(this, other);
log("%d : returning\n", this>other);
};
int main() {
coro f1, f2;
coro_init(f1, fn, f2);
coro_init(f2, fn, f1);
log("resuming %d\n", f1>f2); coro_resume(f1);
log("resuming %d\n", f1>f2); coro_resume(f1);
log("resuming %d\n", f2>f1); coro_resume(f2);
log("resuming %d\n", f2>f1); coro_resume(f2);
}
main     : resuming 1
fn : 1 : entering then yield back to calling
main : resuming 1
fn : 1 : yielding to 0
fn : 0 : entering then yield back to calling
main : resuming 0
fn : 0 : yielding to 1
fn : 1 : returning
main : resuming 0
fn : 0 : returning
main :
>>
>>56772308

https://www.schoolofhaskell.com/school/to-infinity-and-beyond/pick-of-the-week/coroutines-for-streaming/part-2-coroutines
>>
>Programming for five hours
>Haven't tested it once
oh man this is gonna be fun
>>
>>56772430
5 hours of code = 5 minutes of fixes
>>
>>56772458
that's not always my experience
Sometimes fixing stuff is fast, sometimes it isn't. If you're really unlucky, you can get a compounding problem early on.
>>
>>56772246
Delusional idiot. Try it if you dare.
>>
>>56772474
you misunderstand
it's not monotonic
>>
>>56772474
Do you not plan out what you're doing before you start typing?
>>
>>56772430
>write 3000 lines of code
>compiles the first time
its pretty great.
>>
>>56772488
You can plan out what you're doing, and still make incorrect assumptions.
Alternatively, you could look back after hours of working and realize that X Y Z thing you did was bad for A B C reasons and decide to delete huge chunks of code to try and make it work better
I don't know about you but personally I make mistakes/bad judgment calls sometimes, or just flat-out make incorrect assumptions (this is especially applicable to things like Unity, where things might operate in bizarre and unexpected ways, requiring workarounds)

>>56772498
Even better feel
>write 3000 lines of code
>it compiles and functions exactly as it's supposed to
best feel
>>
>>56772498
it's called haskell
>>
>>56772498
>Having code not compile
What? What environment are you writing in that won't even warn you if something will prevent your code from compiling?
>>
>>56772195

It's a copypasta, and you won't find any proof of this actually happening.

>>56772246

I'm pretty sure Canonical and Redhat are not just neet basement dwellers. I think if you fucked with them, you'd get a pretty hard corporate dicking.
>>
>>56772498
All javascript code compiles successfully.
>>
>>56772635

Here I will make a bold assertion: All C code will compile successfully. This is a tautology, because if one were to present an example program that is rejected by a standards compliant C compiler, by definition, it is not a C program. I will henceforth say that for all programming languages x, a program written in x will compile.

But this is meaningless, isn't it?
>>
>>56772684
Depends on your definition of "successfully" for the context. Plus depending on your compilation options you could have valid C not compile.
>>
>>56772684

For the purposes of this experiment, are we suggesting that C + extensions is actually invalid C that only works as a courtesy?
>>
>>56772704
We are assuming that the compiler is not being told to intentionally not compile valid C, as with a flag like -Werror. Something like -pedantic-errors should still compile all valid C, however.

>>56772706
I am stating that all valid C is accepted by a standards compliant C compiler, because by definition a standards compliant C compiler must accept every valid C program. I am making no statements about invalid C programs being accepted.

Also, I may have to amend my statement in >>56772617

"for all programming languages x which are not compile-time turing complete, a program written in x will compile"

Forgot for just a moment that not all C++ programs will compile. Some valid programs may cause an infinite loop... or some standards compliant compilers may just flip the table and quit because of too deep of recursion depth.
>>
>>56772765
>I am stating that all valid C is accepted by a standards compliant C compiler

That's not true, either. A C99 program cannot be compiled by a C89 compiler, despite the latter being standards compliant.
>>
>>56772784

Can we at least make an assumption of same version?
>>
>>56772784
A C89 compiler is not standards compliant. It just used to be, and we indicate at one point it stopped being compliant with the changing standard with the version.
>>
>>56772806

I dunno, man. Assumptions are bad news.
>>
>>56772684
>for all programming languages x, a program written in x will compile.
what if the compiler depends on external state?
>>
>>56772815

What about a _Static_assert?
>>
>>56772808

The ANSI C standard is still valid, though. A C89 compiler is compliant with the C89 standard, and is therefore standards compliant, just not C11 compliant.
>>
>>56772765
what about this? http://stackoverflow.com/questions/5508110/why-is-this-program-erroneously-rejected-by-three-c-compilers
>>
>>56772853

Because it's not a valid C++ program.
>>
>>56772892
how so?
>>
>>56772853
Possibly the best stackoverflow post I've ever seen.
>>
>>56772853
>>56772892
You may have to amend your statement to incorporate implementation-defined behaviour.
>>
>>56772900

Does this look like a valid C++ program to you?
>>
>>56772842
ANSI C is valid ANSI C. It is not necessarily valid C
>>
>>56772976
Show me where in the C standard it specifies that C programs must consist of ASCII characters in a file. Hint: it doesn't. Read C99 1.2
>>
>>56772976

Why are you using Unity?
>>
File: Screenshot_2016-09-25_17-26-41.png (96KB, 757x599px) Image search: [Google]
Screenshot_2016-09-25_17-26-41.png
96KB, 757x599px
What does const vector<string> do in cpp? These are chess positions hardcoded into an engine.
>>
>>56772998
Defines a constant vector of strings
>>
>>56772976
the braces seem to be matched
>>
>>56773010
What is a vector in cpp?
>>
>>56773041

The only data structure you'll really ever need.
>>
>>56773041
http://www.cplusplus.com/reference/vector/vector/
>>
>>56772990
Doesn't say it has to be ASCII, but C11 5.2.1 does seem to suggest a requirement for a character set of some variety, none of which is present in a .png image encoding handwriting.

>>56772993
I'm a lazy fuck.
>>
>Learning vulkan
Just kill me.
>>
>>56773095
Thats going bit far sometimes you need a map preferably unordered_map, for everything else there is vector
>>
>>56773099
Yeah, thanks for spoonfeeding.
I googled it.
>>
I'm giving up on visual studio this new 2015 is hanging pretty frequently and is becoming annoying to use and this is fresh windows install... Installed CLion and its speedy in comparison.
>>
>>56773102

Actually wait... fuck, forgot this was C++ again.

Oh well, the rules are probably similar in this regard.
>>
>>56773102
Yes, that's the source character set. The standard is written in terms of abstract "source characters", so that it can refer to particular characters without having to specify an encoding for those characters. So, for example, you could write a standards compliant compiler that operates on UTF-16 files.

The only way this can work is if the standard does not specify how this translation is performed. And it doesn't: 5.1.1.2.1.1 says "Physical source file multibyte characters are mapped, in an implementation-
defined manner, to the source character set (introducing new-line characters for
end-of-line indicators) if necessary.)"
So the implementation could very well specify that the translation is performed by interpreting the image as a PNG and doing OCR.
>>
>>56773041
a misnamed data structure
>>
>>56772308
got it nicely working now.
coroutines can share values, so i can make generators now,
they can return something when its returns, and actually checks if it has returned.

implemented some examples like the same fringe problem.
>>
>>56773160
I know that one of the main dev of Visual Studio actually programs it with ... Vim
>>
>>56773290
I use vim for smaller projects but for large projects i have hard time using it effectively. For small under 1ksloc its great
>>
>>56773314
What issues do you run into for larger projects? I use it at work where my team's codebase is in the 100ks of lines of code.
>>
https://www.youtube.com/watch?v=TQpfpVD6vC8

nano bros ww2
>>
>>56771190
Game of life?
>>
>>56773330
I have hard time navigating through dozens of files, even with nerdtree. Also having go to definition is must sometimes. I would also like autocomplete for types. I never managed to configure vim for c++ and c as good as some other languages...
>>
>>56773345
Have you ever seen Game of Life before? That doesn't look anything like it.
>>
moved away from autotools to meson
https://github.com/vaccineapp/vaccine

yaourt -S vaccine-git
>>
>>56773353
>I have hard time navigating through dozens of files, even with nerdtree
I've never needed it myself, but I've heard fzf is meant to be pretty good.

>Also having go to definition is must sometimes.
True. I find this less necessary because we have an internal code search tool which can do this and much more.

>I would also like autocomplete for types. I never managed to configure vim for c++ and c as good as some other languages...
Have you tried YCM? I use C++ at work, and YCM handles this quite well.
>>
Is Visual Basic useful?
>>
>>56773353
ever heard of YouCompleteMe ?

https://valloric.github.io/YouCompleteMe/

It does use the clang compiler to provide semantic auto completion.
>>
>>56773387
>Not CMake
Literally deprecated.
>>
>>56773401
No. These days it's just C# with a crappier syntax.
>>
>>56773406
>>56773397

Does it require any additional plugin for clang complete?

I have it but it just completes what i have already written and some other things. Nothing like clang semantic
>>
File: 1373694480124.png (284KB, 696x542px) Image search: [Google]
1373694480124.png
284KB, 696x542px
>>56773387
>yaourt
>not trizen
>>
>>56773416
>running perl code
>>
>>56773373
ctrl-p for easy file navigation, youcompleteme for completion, ctags for jumping to definitions
>>
>>56773414
God damn it. That's what I figured, thanks though.
>>
>>56773415
Semantic completion only triggers on ".", "->", and "::" for C++, but you can manually invoke it at any time with Ctrl-Space.
>>
>>56773416
How does that compare to packer?
>>
>>56773433
It can be configured to complete on any arbitary sequence
:help g:ycm_semantic_triggers
>>
>>56773415
https://valloric.github.io/YouCompleteMe/#c-family-semantic-completion
>>
>make program in python
>takes 7 seconds to execute
>rewrite it almost 1:1 in C

real    0m0.002s
user 0m0.000s
sys 0m0.000s


snekfags will defend this
>>
>>56773449
I'd like to see the programs in question
>>
>>56773449
how fast does it run under pypy?
>>
>>56773446
>>56773442
>>56773426
Thank you kind anons, I'll go now and configure it
>>
But can it toast bread?
>>
>>56773442
Do you know how to configure it to trigger on any identifier character? Setting to 're!.' works to trigger on everything, but 're![a-zA-Z_]' doesn't seem to work for just identifier characters.
>>
>>56773537
>Crying with cum
>>
>>56772976
>unity
>sublimetext
>hexchat

kek, the usual casual script kiddie.
>>
>>56773454

That is a pizza, likely ruined from the fact that you put it in a dusty drawer. One should not ruin good food.
>>
for someone who knows nothing about programming, what do I need to learn to program vst, plugins, or other audio related stuff?
>>
>>56773698
C
>>
>>56773698
fortran
>>
>>56773698
html
>>
>there are more game engines made with c++ than atoms in the universe
>none of them export C api
>>
>>56773825
So make one that does.
>>
>>56773825
Why would you export C api? When everybody uses c++. Its like exporting rust api
>>
>>56773825
https://www.youtube.com/watch?v=D7Sd8A6_fYU
>>
They say you shouldn't use raw new/delete and raw pointers in modern C++ code, but what about when I'm writing a low-level container class for POD? The user *never* has a direct access to the raw underlying data (all access is checked) and I'd love to keep the container standalone, not have it depend on any existing std class.

My program is already suffering from template bloat madness (I have probably 150 different std::vector<> types and a few dozen std::maps), I'd love to not increase it further but just use a plain raw array for the data.
>>
>>56773607

>casual script kiddie
I have a Bachelor's Degree in Computer Science, and a research grant from the Office of Naval Research coming in relatively soon. Fuck off.

>>56773830

C ABI is the gold standard for Foreign Function Interfaces. Everything talks to it. not everything talks to C++.
>>
>>56773995
there no such thing.
>>
>>56773995
>a research grant from the Office of Naval Research
researching what exactly?
>>
File: Screenshot_2016-09-25_20-05-09.png (74KB, 1280x800px) Image search: [Google]
Screenshot_2016-09-25_20-05-09.png
74KB, 1280x800px
In python does it take more memory to call a function which takes an array as input than to just read from the original array? I have lots of copy-pasted code, and I'm not if it costs me anything to make it a function. For example, the code for working out the horizontal and vertical moves is the same for the queen and rook.
>>
File: 1472396833861.png (124KB, 5000x2571px) Image search: [Google]
1472396833861.png
124KB, 5000x2571px
so i was reading about vector math and i got to this part
var distance = normal.dot(point)

what the hell is this? i thought dot product returns scalar in range from -1 to 1, can someone help me understand it?
>>
>>56774187
Research is easy, learn how to do it.
https://en.wikipedia.org/wiki/Dot_product#Algebraic_definition
>>
>>56769744
For telling the CPU what to do.
>>
>>56774187
Dot product doesn't have to be from -1 to 1. It is equal to either the sum of the product of the coefficient of each basic unit vector or the product of the magnitude of both vectors times the cosine of the angle between their tails.
>>
/dpt/-chan, daisuki~

>>56773449
>No source code provided
Irrelevant

>>56773106
Many thought Vulkan would be easier than OpenGL but it's actually the inverse; You have to implement many facilities offered by OpenGL.

>>56772430
Time to learn TDD.

>>56772308
No preemption ?

>>56769896
The alternative to imperative (statements) is declarative (everything is an expression).

>>56769744
Turing machine.

>>56769643
You could have reduced
def mainComp():
return max({ comp(a**b) for a in range(1, 100) for b in range(1, 100)})

def mainLoop():
return max({ loop(a**b) for a in range(1, 100) for b in range(1, 100)})


to the following function
def main(fun):
return max({ fun(a**b) for a in range(1, 100) for b in range(1, 100)})


For the performances, sum is slower in this case probably due to
(int(i) for i in str(n))
. Otherwise, it's faster. (pic)

>>56769519
Thank your for using an anime image
>>
I have down syndrome and have severe problems writing bash scripts because I am a Python babby.

patch_num = "119373-33"
regex = re.search(r'(\d{6}-)(\d{2}))', patch_num)
print regex.group(1)


The following code should probably get me
119373-
. What's the bash equivalent?
>>
>>56774554
Sorry, and most importantly, what's the syntax so that
var = regex.group(1)
>>
Where to learn x86 assembly using AT&T

anyone know a good resource?
>>
>>56774660
Professional Assembly Language
>>
>>56774707
thanks i think this will do exactly
>>
>>56774106

What, the Office of Naval Research? Yes, it's a thing.
http://www.onr.navy.mil/

>>56774123

Well, about two days ago, it was going to be analyzing the possibility of an algorithmic complexity attack on some industrial controllers. That said, the professor I'm working on this with had some issues in actually getting those controllers. So we've thus changed the topic to one that's involving analyzing some malware that's been propagating itself through a particular network protocol. I've got a bit of reading up to do on this thing tomorrow.
>>
>>56774175
If you started caring about memory usage, you should move away from Python.
>>
>>56774872
I think you might be right.
Python is so comfy though. It's so much more intuitive just to indent rather than to have to surround everything in braces. It's also nice not having to deal with low level data management stuff constantly.
>>
>>56774914
Why not just refactor to use functions and actually profile it first?
>>
>>56774914
haskell doesnt have braces and is high level
>>
>>56774914
Try Go. Many Python devs migrate because it's not that much more complex to write, readable and much much more performant.
>>
Learning some WebGL. Why is Javascript so comfy, /dpt/?
>>
Could someone explain the benefit of creating Interfaces in C#? (and presumably other languages that support interfaces).

Is it just to assist in design so you don't forget a class? Or can you start prototyping your code with an interface, even if there is no actual code?
>>
Poorfag question, can anyone share a cracked or licensed 32bit themida?
>>
>>56774935
I haven't got it running yet. At the moment I only have a generator for pseduo legal moves. Can't really test it until later.
>>56774938
>>56774949
I'll try them out. I'll probably stick to python for this project unless it becomes unwieldy because I want to get good with it before moving on.
>>
>>56774969
If you think js is comfy, check out Elm.
>>
>>56775004
Interesting, thanks. Although I don't particularly like languages that compile to JS but will check it out nonetheless.
>>
>>56774969
Why aren't you using ES6? The only browsers that don't support it are IE and Apple IE aka Safari. http://kangax.github.io/compat-table/es6/
>>
>>56775029
Because Safari is my main browser, mainly because of battery life :(

Also I'm not familiar with ES6 yet. First I'm going to focus on WebGL.
>>
>>56775048
You're living your life incorrectly.
>>
>>56769519
What should I use for a github porfolio? I am looking to start some simple projects to fill it, do you any suggestions on what potential employers would be interested in seeing?
>>
>>56774949
https://docs.google.com/presentation/d/1LO_WI3N-3p2Wp9PDWyv5B6EGFZ8XTOTNJ7Hd40WOUHo/mobilepresent?pli=1#slide=id.g70b0035b2_1_168
>>
>>56774982
Interfaces abstract away implementation and only show behaviour. The actual implementation of the code might differ, but the code on the caller side always looks the same, which is a good thing.
>>
>>56775239
>Interfaces abstract away implementation and only show behaviour.
>failed oop 101
objects do that. interfaces are only about typing.
>>
>>56775239
>Interfaces abstract away implementation
thats literally what they dont do
>>
>>56775415
He is right you dumb fuck. An interface is a type of contract, the concrete implementation of the behaviour is done by the class. Take a look on how Inversion of Control works for example.
>>
>>56775415
Not OP but I thought interfaces describe a set of behaviors. Like a Stack interface describes operations you can do to a Stack. An implementing class might use an array, or linked list, or whatever, but it has to provide all the operations. Isn't that abstracting implementation from behaviors?
>>
>tfw Python is actually a sane language
Am I the only one who likes Python?
>>
>>56775471
yes, it's a typing contract and nothing more. it's not the interface which abstract the implementation, it's the object and its polymorphic semantics.

>>56775478
>I thought interfaces describe a set of behaviors
No, an interface describe an interface and no more. it's the implementation of the object (class, prototype, ...) which describes the behaviors.

Interface are only there for the type system. take the dynamically typed languages where interfaces are useless, you can still abstract the implementation because it's the objects which does that.

example
sort(o)
{
o.sort();
}


interface are just here to add more typing safety

sort(Sortable o) // ensure o has the sort operation
{
o.sort();
}


but it doesn't enhance the abstraction of the implementation.
>>
>>56775529
Quality bait mate
>>
more like poopthon amirite xD
>>
Racket is so comfy
>>
>>56775589
Racket is my awesome. What do you do with it? I cant find interesting toy project
>>
>>56775606
Keepad simulator
>>
>>56775589
input in racket is painful.
>>
>>56774938
It does have braces, but they're optional.
main = do {
putStr "Enter your name: ";
name <- getLine;
putStrLn $ "Hello, " ++ name ++ "!";
}
>>
>>56775709
>til
everyday something new
>>
>>56775548
I guess I was thinking more like a class or prototype describes the implementation of a behavior, while an interface only describes what behaviors an item has. Is that the same as what you're saying?
>>
Python is basically a Lisp with better syntax, more libraries and no macros.
http://norvig.com/python-lisp.html
>>
>>56775749
yes because as we all know python is actually made of s-expressions
>>
>>56775743
The interface (not talking about typing here) of an object is the set of operations the object has. The behavior of these operations is described in the implementation of the said operations.
>>
is this the best book for learning Python? For a sort of newb. Listening to recommendations. Also, has to be Python 3. Thanks!
>>
>>56775760
>>> parse("2 + 2")
['eval_input', ['testlist', ['test', ['and_test', ['not_test', ['comparison',
['expr', ['xor_expr', ['and_expr', ['shift_expr', ['arith_expr', ['term',
['factor', ['power', ['atom', [2, '2']]]]], [14, '+'], ['term', ['factor',
['power', ['atom', [2, '2']]]]]]]]]]]]]]], [4, ''], [0, '']]
>>
>>56775856
I'll be damned
>>
how to make this shorter?

template <class T1, class T2>
bool intersecting(T1& mA, T2& mB)
{
return mA.right() >= mB.left() && mA.left() <= mB.right() &&
mA.bottom() >= mB.top() && mA.top() <= mB.bottom();
}
>>
>>56775850
That dude's a fool. It's like "learn shit by typing it wrong then fixing it". Nah just learn it right and reinforce good behaviors.

http://inventwithpython.com/chapters/
http://greenteapress.com/thinkpython/html/index.html
http://openbookproject.net/thinkcs/python/english3e/index.html
http://interactivepython.org/runestone/static/thinkcspy/index.html
>>
File: cake.webm (447KB, 900x506px) Image search: [Google]
cake.webm
447KB, 900x506px
>>56775850
https://www.cs.hmc.edu/csforall/
http://www.composingprograms.com/
http://programarcadegames.com/index.php?lang=en
>>
>>56775856
Sheesh, no wonder Python is too slow.
>>
>>56775029
the table you linked shows 100% compatibility for safari 10
>>
>>56776013
Oh, you're right. Never noticed that actually changed.
>>
you guys drink coffee right
>>
>>56776219
No you fucking hipster, go back to your python/ruby project
>>
File: le straight edge trump.jpg (240KB, 1500x822px) Image search: [Google]
le straight edge trump.jpg
240KB, 1500x822px
>>56776219
Nope.
>>
>>56776219
tea master race
>>
>>56776252
Black white or green tea?
>>
https://youtu.be/D7Sd8A6_fYU

they're getting desperate
>>
>>56776256
oolong
>>
File: serveimage.jpg (61KB, 640x480px) Image search: [Google]
serveimage.jpg
61KB, 640x480px
>>56776233
>le
go back to /pol/eddit you dumb drumpftard
>>
>>56776280
master race indeed!
>>
File: C++.png (54KB, 972x259px) Image search: [Google]
C++.png
54KB, 972x259px
>>56776277
>>
>>56776219
Caffeine + L-Theanine FTW
>>
>>56776277
>compare c performance to c++ with example where he is using c++ as c with classes.
>using c++ does not force you to use all of it's "nice" features so it's valid
>proceeds to lecture that c++ is better than c because it has those "nice" features.
>>
>>56776219
Yes. Also a beer everyday after work, helps me slow down and relax. And if I'm very stressed or anxious that day a cigarette too.
>>
>>56776305
what's your preference?
>>
>>56776395
I used to drink alot of oolang as well but in last couple of months im hooked on linden and common mallow i buy those from some old man here all fresh and pretty cheap.
>>
>>56769519
kill yourself faggot
>>
>>56776467
calm down anon, did you lose your free software?
>>
whats some good software for planning and designing apps? trying to get into android dev
>>
>>56776497
java is horrible
>>
>>56776460
Those are flower teas right? I still have some tea left that I bought in China and Taiwan. Tea shops here are overpriced and only serve fine grained tea.
>>
>>56776538
Leaves as well flowers. Linden and mallow are grow here i even had mallow in my garden few years ago.

Good tea is expensive here as well unless you find someone. Or if you want to drink that tea bag garbage
>>
>>56776501
everyone on this site says everything is horrible. why do you think that is? maybe people are pretending to be the authority in what's in and all that?
>>
>>56776575
they don't say equally for all things

java is literally horrible
>>
>>56776575
All people here can agree that Java is horrible. The only Java advocates are trolls.
>>
>>56776597
>java is literally horrible

hurr durr
>>
>>56776694
nigger boi plz
>>
File: 26375861581.png (75KB, 430x546px) Image search: [Google]
26375861581.png
75KB, 430x546px
#56776694
0/10 terrible shitpost no (You) for (You)
literally less funny than javafag
>>
>>56776702

Nigger women need love, too.
>>
File: dman.png (14KB, 160x301px) Image search: [Google]
dman.png
14KB, 160x301px
>242 posts in
1st for dlang :>
>>
>>56776816
sasuga d performance
>>
Ultra noob python question.
I'm trying to find the first number that can be divided by 3 and by 5 (which is 15) using "if".
What am I doing wrong?
>>
File: pixel_rain.gif (51KB, 500x376px) Image search: [Google]
pixel_rain.gif
51KB, 500x376px
>use SQL regularly at work
>think I'm good with it
>apply for job, they give SQL test
>first question easy
>second question to do with partitioning tables to get the difference between the max and second-to-max values in column B for each unique value of a column A
>mfw I realise I don't know shit about SQL

How do I git gud?
>>
>>56776834
As expected from a Python user
>>
>>56776865
Come on man, I'm trying to learn. Do you know what I am missing?
>>
>>56776834
1. look at your while line. think about what will cause that to be false
2. i don't think you should have to check twice, but that's not fatal
>>
>>56776881
That's small enough you could just write out the values of the conditionals for j = 1, 2, 3 and figure out whats wrong.
>>
>>56776853
alias 'gud' to 'log' in your .gitconfig
>>
File: 1469011019713.jpg (29KB, 600x456px) Image search: [Google]
1469011019713.jpg
29KB, 600x456px
>tfw you live in the worst timeline where javascript is used instead of Racket
>>
>>56776957
>implying there's a timeline where Scheme and derivatives became popular
>>
>>56776957
Lisp is cancer
>>
>>56776990
Do most of the /g/ tards actually have jobs that involve the austist programming languages?
>>
File: 1451434814905.png (267B, 400x500px) Image search: [Google]
1451434814905.png
267B, 400x500px
>>56776957
nobody stops you from writing something meaningful in the programming language of your choice. stop being a little crybaby and go to work now!
>>
listen to >>56776904 also. if you're exceptionally lazy you can make the program print it all out. but step through the logic somehow (it is just a flaw of logic, not programming really)

i'll say more once you've found it
>>
>>56776834
you're essentially doing
while not divisible by 3 and 5: check if divisible by 3 and 5
>>
File: sussman shig.jpg (71KB, 500x375px) Image search: [Google]
sussman shig.jpg
71KB, 500x375px
>>56776978
>implying javascript isn't a scheme
>>
>>56776834
print 15
>>
File: 57760720_p0.jpg (557KB, 1396x1980px) Image search: [Google]
57760720_p0.jpg
557KB, 1396x1980px
>>56776978
I am sure there is a timeline where everyone uses lispmachines and care about freedom
>>
File: 1471844517217.jpg (162KB, 898x709px) Image search: [Google]
1471844517217.jpg
162KB, 898x709px
>>56777180
>javascript
>scheme
When will this meme die
>>
>>56773449
Yes, Python is slow but it's good enough for automating shit because with all the stuff that you can outright import you can be done with it in a few minutes.
>>
>>56777215
aoba a qt :3
>>
>>56773449
It's good for automation and when you're I/O bound.
>>
>>56773458
pypy still runs like shit.
A Python JIT will never reach the performance of other JIT'd languages until someone rewrites the entire standard library in Python.
>>
>>56777262
should I watch new game?
I know to expect moe sol but is the humor at least oriented on IT stuffs?
>>
>>56777355
I like it. It's office humor with an IT twist.
>>
>>56777337
Why is that? You'd think the parts written in C would be fast.
>>
>>56776316
holy shit
he's the ultimate troll
https://www.youtube.com/watch?v=_wzc7a3McOs
>>
>>56769519
doing c# winforms simple program for handling factures, customers and items with sqlite. i was trying to google how to use entity framework with sqlite, didnt find anythign useful and went with raw sql queries. ill never make same mistake again
>>
>>56777479
JITs can remove runtime-dependant dead code like type checks and stack checks. The Python C runtime contains those unnecessary dead code segments, they are compiled in, the JIT can remove them. Rewriting the runtime in Python would allow the JIT to decide how to compile the procedures using what it knows at runtime.

JITs can theoretically be more performant than AoT compilation because the optimizations available to JITs that aren't available before execution. There was a paper about it, forget the name, if you were interested.
>>
>>56777684
how can i know stuff like this about languages and such?

you seem to know about this
>>
>>56777703
Read papers and blog posts by core developers. I learned a bunch from reading blogs by the V8 devs.
>>
>>56777727
>I learned a bunch from reading blogs by the V8 devs.
post links pls
>>
>>56777703
I read papers on programming for fun. And I read source code.
Recent papers include:
Multi-stage programming, MetaOCaml
https://www.cs.rice.edu/~taha/publications/journal/gttse07.pdf
Memory's effect on performance optimization
https://people.freebsd.org/~lstewart/articles/cpumemory.pdf
Using stack-ful asymmetric coroutines to implement more general flow control devices like continuations
http://www.inf.puc-rio.br/~roberto/docs/MCC15-04.pdf

Been pouring through this, reading every revision he makes, sending him emails every so often about improvements. Make might implementing this on an FPGA my master's. Other possibility is profile-guided optimization of memory allocation.
http://www.agner.org/optimize/instructionset.pdf

Been going through the LuaJIT source code too. It's pretty dense.

Will be going through implementations of arena-based allocations soon so I can attempt to make a new garbage collector for the LuaJIT.
http://wiki.luajit.org/New-Garbage-Collector
It probably won't be accepted, Mike's code quality requirements are impossible.

Somewhere along the way I came to "know stuff".
>>
>>56777744
Can't find them anymore. Just search around for V8 inline caches or similar.
>>
>>56777853
BASED

thanks
>>
>>56777337
pypy is quite fast actually

>until someone rewrites the entire standard library in Python.
which is what pypy actually did.
>>
>>56771957
go back to gmod sex poses and rust, faggot
>>
>>56777877
I was just showing what I've been doing. I wouldn't suggest reading any of that (except maybe the one on memory performance) unless you have a background in the material.

Just pick a programming topic you like and start googling for papers and code.
>>
>>56775957
???
>>
>>56777884
I've tried it on most of my project Euler code. It wasn't any faster. Most of my solutions make use of itertools and comprehensions, are those things they haven't gotten to yet?
>>
>>56777907
dumb tripfag
Interpreters work on parse trees => larger parse trees mean more overhead in interpretation
>>
>>56777931
but python is faster than C
see >>56777479
>>
>>56777931
>dumb tripfag
you wot?
>>
>>56769519

what is a way to manipulate PNGs with java or python?
>>
>>56777950
bullshit
>>
>>56774914
Haskell has performance similar to Java. If you want to learn a new low-level language for your projects that need more power than Python, try Rust. I wouldn't recommend Go, it's trying to be too simplistic by not having abstractions etc. which ends up hurting the simplicity. Haskell is an academic language to learn how functional programming works, it sucks when you try to do actual real-world stuff in it.
>>
>>56777974
>it sucks when you try to do actual real-world stuff in it
[ citation needed ]
>>
>>56769519
If you think that is cool , try taking code with a BSD licence, those cucks cannot even try stopping you
>>
>>56777684
>the JIT can't remove them*
I always miss the most important contractions.
>>
>>56777974
I've written a few projects in Haskell and it's one of my favorite languages to use... Once you wrap your head around it, it's super nice to use for real-world stuff.
>>
>>56776834
counter = 1
while not (counter % 3 == 0 and counter % 5 == 0):
counter += 1
print(counter)

Your logic is sub-par. I recommend you try gaining a lot more programming experience, or you'll fail at your class.
>>
>>56778023
unless the "real-world stuff" involves things you're doing for a real company, because dealing with the Haskell tooling is shit. hopefully some combination of NixOS and Stack can help combat this, but most Haskell users seem to still be using Cabal
>>
>>56778076
there's nothing wrong with cabal
>>
>>56778083
it's terribly broken, and a very poor excuse for a package manager
>>
>>56769519
You know... forking projects on github isn't illegal, right? The whole point of "free software" is that you can do whatever you want with the code. If the company that hired you didn't fact-check you, well, that's their problem.
>>
File: bjarne.png (91KB, 136x275px) Image search: [Google]
bjarne.png
91KB, 136x275px
He's like a gnome
>>
>>56778102
I say cabal install and it installs a package

What's broken?
>>
>>56778076
I've been using Stack, no hangups on our deployments.
>>
>>56777974
Haskell has CPU performance similar to Java, but it's memory usage is much lower (about 1/2-1/4 in most benchmarks I've seen). Of course, it's still not as fast as C/C++/Rust.
>>
>>56778167
Haskell's got loads of room for completely impractical optimisations

Pretty sure the reason they haven't made progress on supercompilation is because it produces huge executables
>>
>>56778129
>>56778102
Cabal isn't a package manager, it's a build system.
>>
>>56778167
I've seen some haskell benchmarks that put it at even w/ C & C++
>>
File: wow anon.jpg (78KB, 884x574px) Image search: [Google]
wow anon.jpg
78KB, 884x574px
>>56778167
>it's still not as fast as C/C++/Rust.
C clang:                        9.971914301 seconds time elapsed
C++ clang++: 5.518077517 seconds time elapsed
C++ G++: 4.659448453 seconds time elapsed
Haskell GHC: 0.454930841 seconds time elapsed
Java OpenJDK: 1.189619693 seconds time elapsed
>>
>>56778209
>>56778217

In very specific circumstances with highly optimised programs, or in situations where you're comparing it with enterprise OOP or shitty algorithms
>>
new thread when ? :3
>>
>>56778217
Nice weighted number generator.
>>
>>56778217
Code or link?
>>
>>56778148
yeah, it's just that until the wider portion of the Haskell community accepts Stack as the superior platform, it's off-putting to businesses
>>
>>56778217
Benchmarks without source code don't mean anything.
>>
>>56774175
what kind of editor is that anon

looks nice n clean n comfy
>>
>>56778331
Vim.
>>
>>56778148
What is Haskell even used for in industry? Every language has it's niche. I would think DSLs, but I can't think of anything else.
>>
NEW THREAD!!

>>56778372
>>
>>56774175
Sure seems like the first few cases could be generated. When will true metaprogramming become more common? Yeah, higher-level functions, blah. blah, blah.
>>
>>56778344
We use it mostly for backend APIs, but also have a couple CLI utilities for manipulating infrastructure.

Safety, best type system, easy refactoring, etc. make it super nice to program in, and my preferred general language for personal projects.
>>
>>56774969
I prefer coffeescript.
All of the comfy with none of the syntactical bloat
>>
The DNS module for dpkt is a piece of shit. It took me quite a while to discover that it doesn't support DNS over TCP, so I have to strip the 2 byte length from the beginning of the DNS header in order to get it to parse.
Thread posts: 320
Thread images: 33


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.