[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: 318
Thread images: 39

File: prog.jpg (105KB, 473x496px) Image search: [Google]
prog.jpg
105KB, 473x496px
What are you working on, /g/?
Old thread: >>60428175
>>
First for Haskell generating garbage 1GB/s
>>
I am trying to re-implement getopt() properly.

Currently getopt() sucks in
1. Indexing inputs
2. Multiple flagged inputs
>>
>>60435198
That's 6 GB/s for you :^)
>>
>>60435165
i really like this op image
>>
File: programming language benchmark.png (183KB, 1050x750px) Image search: [Google]
programming language benchmark.png
183KB, 1050x750px
First for Java is the choice for high performance computing
>>
What is man supposed to use when here's just no good statically typed and compiled language.
>sml
no good implementaion
>ocaml
sml with shitty syntax, also does not support native threads
>lisp
too verbose, also static typing not standardized
>c
decent but manual memory management is annoying in prototyping phase
>sepples
cluster fuck that no sane person would touch
>d
can't decide if it wants to have gc or no
>rust
better stay away from it because it attract lot of crazy hipsters, also uglier than sepples
> any jvm/clr lang
requires HUGE vm
>go
Rob Pike is faggot, also no macros
>haskell
generates garbage 1GB/s
>chapel
uses more memory than java
>nim
lol python like syntax, also buggy
>>
>>60435466
pure asm, platform independent high performance code is a meme
>>
>>60435466

Java
>>
>>60435513
Nobody gives shit about performance.
AST might be decent but the different syntax for manually memory managed stuff and garbage collected stuff seems really annoying.

>>60435537
HUGE VM
>>
>>60435563
>AST
meant ATS
>>
File: skilled.webm (3MB, 720x404px) Image search: [Google]
skilled.webm
3MB, 720x404px
>>60435466
There a lot more than those.

>>60435343
I second this

Java OpenJDK:                   1.189619693 seconds time elapsed
C clang: 9.971914301 seconds time elapsed
C++ clang++: 5.518077517 seconds time elapsed
C++ G++: 4.659448453 seconds time elapsed
Python CPython: 77.788729238 seconds time elapsed
Python PyPy: 46.487679095 seconds time elapsed


>>60435165
Thank you for using an anime image.
>>
>>60435334
me too anon
>>
>>60435563
if you dont give a shit about performance then who cares about your code being statically typed and compiled
>>
>>60435634
Deploying native executables instead of requiring userbase to install HUGE vm / interpreter.
I prefer static typing to dynamic in big projects because you can detect stupid mistakes in compile phase.
>>
>>60435563

>HUGE VM

Oh wow 50MB whatever will you do without that.
>>
ive got some free time, so right now I'm working on a dubs script, then im gonna try to make a autoheal for this one .io game
>>
>>60435707
I used chromebook with 16gb ssd for year and usually had only few hunded mb free for additional programs so jvm was no no. Also the trend seems to be smaller devices with 32/64 gb ssd and when most of that space is filled by 100mb web apps making your applications space efficient matters.
>>
File: 1493911072573.gif (2MB, 400x209px) Image search: [Google]
1493911072573.gif
2MB, 400x209px
is this better now?
|0000000|00000|00000|0|00|0|000000|00000|
|opcode | re1 | re2 |0|00|i| fun | re3 | integer register

|0000000|00000|00000000|1|000000|00000|
|opcode | re1 | litr |i| fun | re3 | integer literal

|0000000|00000|00000|0000000000|00000|
|opcode | re1 | re2 | function | re3 | flaot

|0000000|00000|00000|000000000000000|
|opcode | re1 | re2 | displacement | memory

|0000000|00000|000000000000000000000|
|opcode | re1 | displacement | branch
>>
>>60435319
That's a big number.
>>
File: THINKING EMOJI.png (53KB, 256x256px) Image search: [Google]
THINKING EMOJI.png
53KB, 256x256px
>>60435760

No that is absolutely not the trend you pleeb
>>
>>60435343
What were the compiler options for C and C++?
I'm guessing that part of the reason C and C++ perform worse is O0.
>>
>>60435890
people using laptops with max 128gb ssd where windows takes 30 of it already.
It's delusional to think that "people have enough space" dumb nigger.
>>
File: elpa.jpg (197KB, 800x705px) Image search: [Google]
elpa.jpg
197KB, 800x705px
>>60435948

>98GB free, but no space for 50MB
>>
>>60436004
>he doesn't have 90gb of pictures
You clearly have never seen how poorly people manage space dumb frog poster.
>>
File: our time has come.png (132KB, 500x281px) Image search: [Google]
our time has come.png
132KB, 500x281px
>>60436045

>he just makes up random nonsense to prove his point

You clearly are a buffoon so I say good day to you and stay out of our java territory which is this entire board because this is a java board now so you better like java
>>
>>60436057
Pajeet...
>>
File: our army.jpg (79KB, 700x525px) Image search: [Google]
our army.jpg
79KB, 700x525px
>>60436066

It's too late to stop us now. Our forces are moving into the board.

We have 300 million people of fighting age and that's not even including teenagers who could easily be drafted as child soldiers or people older than 40 who could still fight for the motherland.

Surrender and accept the rule of java or face death.
>>
>>60436183
go shitpost elsewhere nigger.
>>
>>60436218

Uh what did you just say to me paleboy? I'll have you lashed if you do that again.
>>
im working on a ncurses 4chan client

i have reached a new autistic high in my life
>>
Lua > Python >>> JavaScript
>>
>>60436249

You better switch over to java or else we'll send the secret police round
>>
>find a perfect language
>it's either dead or has incompatible versions
>>
>>60435343
Tried it out myself. Using Measure-Command in powershell to benchmark.

C version compiled with GCC -O2:
4172.3 ms
Java version:
4382.8 ms
>>
What is the best programming language and why is it not cinnameg?
>>
What's the most autistic thing you've recently seen?

https://smilebasicsource.com/page?pid=68
Brainfuck compiler to Smile Basic for the 3DS.
>>
>>60436383

Wow even with tough optimisations and hours of meticulous hand crafting C can only just scrape victory over mighty java.

Truly what hope can you have for a C victory against the might of the orange army?
>>
File: 1488398991660.gif (2MB, 311x362px) Image search: [Google]
1488398991660.gif
2MB, 311x362px
>try to start project
>this should be easy
>realise you are shit at programming

Well fuck
>>
>>60436453

Try python instead, it allows everything to work even when it doesn't make sense.

Until you're ready to work with java like a true jarvyan you'll have to stay in the python camp though.
>>
>>60435343

I tried this test with Java, C++, and Rust. The source code for the C++ and Java versions are identical to what you have provided. The Rust version looks like this:

pub fn main() {
let mut n : i32 = 0;
for i in 1..2000000000 {
if i % 3 == 0 && i % 5 == 0 {
n += 1;
}
}
println!("{}", n);
}


I compiled Java using the Oracle Java9 compiler, and tested with the Oracle Java9 VM. The result was a time of approximately 2.83 seconds, both with and without -XX:+AggressiveOpts. For C++, I used g++ 5.4.1 with the -O3 flag, and produced an average runtime of 1.99 seconds. For Rust, I unfortunately have an outdated compiler (rustc 1.7.0, which is what I can get through the Ubuntu 16.04 package manager. I need to get something better via Rustup or something). I compiled with -C opt-level=3, and produced an average runtime of 5.49 seconds. All three of these are on a laptop with Ubuntu 16.04 and a Core i7 6700HQ CPU.

The sizes of the binaries after stripping are as follows:

Test.class: 467 bytes
TestCPP: 6344 bytes
TestRust: 327208 bytes

Conclusion: C++ is a clear winner for speed. Java is better for binary sizes, but this is to be expected from bytecode languages. I will need to test Rust again with a more up to date compiler.
>>
>>60436527
I know that the benchmark itself is trolly shit, but calculating the number of ints divisible by 3 and 5 in O(n) gives me fucking aids.
</autism>
>>
>>60436578

It is, yes. The point of the benchmark, I think, is to show off how Java does in nested loops. The problem with this as a benchmark is that it's the only area where Java does even remotely well.
>>
>>60436277
Garbage > Vomit >>> Diarrhea
>>
>>60436433
>literally just o2
>>
What's the deal with HPC languages like x10, fortress, zpl and chapel?
Are they fit for general purpose programming are they only usable on for distributed systems with at least 128 cores?
>>
>>60436527
>pub fn main()
Why.
What the fuck is the purpose for this.
It makes everything 12 times as hard to read and doesnt save any kind of space.
>>
>>60436509
I use python at work all the time, but it's just for scripts. Least trivial project I've ever done is build a good scraper for LinkedIn, I've never collaborated on a big piece of software.

I'm learning C atm too.

How do I get gud?
>>
>>60436670

Because the creators of Rust preferred shorter keywords. Doesn't make it much harder to read, IMO.
>>
>>60436679
Invest _serious_ amount of time, and emply a healthy amount of self criticizing and you'll be good one day.

Dont be afraid of code review, try reviewing other peoples code, aswell as getting your code reviewed by someone who knows shit.
>>
>>60436527

I've just tried the java one and got 2.4 seconds average for normal and 2.2 by running it through proguard for extra optimisations.

Ultimately, there's not really a big difference in performance. I'd like to see it with python though, I bet that's really horribly slow.
>>
>>60435343
>comparing the performance of a single for loop
>he even compared the binary file size
low quality bait.
>>
>>60436809

Come on then, design a performance test for me to run.
>>
>>60436726

>I'd like to see it with python though
2 minutes and counting at 100% CPU
>>
File: 1493680656328.png (106KB, 862x793px) Image search: [Google]
1493680656328.png
106KB, 862x793px
Holy shit, you fucking retard whoever posted this.
I woke up after the thread had died so I have to reply here.

Rust supports inline assembly in the same way that C supports it, it's just as easy to use and it uses the same syntax.
https://doc.rust-lang.org/book/inline-assembly.html

The only difference, is that in Rust, it's actually standard (minus the actual assembly instructions) unlike in C.
>>
>>60436838

Ouch
>>
>>60436433
In case this wasn't sarcasm:
Java does have the potential to perform well. But it doesn't come for free. C is the same. The difference is in where you put your effort. In Java you have to write code in very peculiar ways and configure your JVM meticulously. In C you have to think about all these low level concerns you might have.

There's some interesting aspects to the Java way a lot of optimization can be done on user machines by configuring your JVM on the fly and asking a server for appropriate settings (for instance). With C that'd be way harder.

So if you actually don't know your platform Java probably wins out for a dedicated developer.
>>60436527
>Test.class: 467 bytes
>TestCPP: 6344 bytes
>TestRust: 327208 bytes
You're forgetting the JVM. It either needs to be installed or packed with the executable.
If you wanted a fair comparison you should look at a CPP where you have dynamic libraries for your standard entry point and standard library in general. Or you could add the jvm to the test.class size.
>>
>>60436383
Also tried Rust:

¨fn main() {
let mut n = 0i32;
let mut i = 1i32;
while {i <= 2000000000} {
if (i%3==0 && i%5==0) {n+=1;}
i += 1;
}
println!("{}",n);
}


gives me 5480.4 ms.
>>
>>60436827
i'm not interested in designing performance tests. why do i need to explain to you that comparing the performance of a simple, single loop is stupid?
>>
Try clang.
>>
File: smug_ran.jpg (632KB, 709x1063px) Image search: [Google]
smug_ran.jpg
632KB, 709x1063px
>>60436827
Calculate BB(10).
>>
rubyist@Overmind:~/cs/scratch/benchmark$ time ./Py3Test.py 
133333333

real 4m38.203s
user 4m38.064s
sys 0m0.048s
rubyist@Overmind:~/cs/scratch/benchmark$ cat Py3Test.py
#!/usr/bin/env python3

n = 0
for i in range(1, 2000000001):
if (i % 3 == 0 and i % 5 == 0):
n += 1

print(str(n))


Gonna test Ruby next.
>>
>>60436893
poojeet
>>
>>60436827
>design a performance test for me to run.
Anon the best performance tests are real world examples.
It's a lot of work though. But you can look to compare different open source software solutions for problems and compare the performance of the C and Java solutions and consider the effort that was put into it. That's a shortcut. It might take a day or two but you will come out wiser.
>>
File: question mark face abstracted.png (8KB, 687x450px) Image search: [Google]
question mark face abstracted.png
8KB, 687x450px
>>60436908

???
>>
rubyist@Overmind:~/cs/scratch/benchmark$ time ./RubyTest.rb 
133333333

real 2m11.256s
user 2m10.872s
sys 0m0.020s
rubyist@Overmind:~/cs/scratch/benchmark$ cat RubyTest.rb
#!/usr/bin/env ruby

n = 0
for i in 1..2000000000
if i % 3 == 0 && i % 5 == 0 then
n += 1
end
end

puts n


Literally half the time of Python.
>>
>>60435165
>What are you working on, /g/?

reading K&R 2nd edition to make a toylang

By the way, I really want to make a toy language but with a big fat stdlib by relying on another language. I was thinking of embedding python in the generated C code (with lots of cool pypi modules) and implement them in C as I find stuff that needs more performance
>>
>>60436950
>doesn't know what the Busy Beaver function is
https://en.wikipedia.org/wiki/Busy_beaver
How's that education going for you, Ranjeet?
>>
>>60436969

That isn't making anything, that already exists
>>
>>60436975

>doesn't know what <NICHE PROBLEM> is

Oh no whatever will I do without <GENERIC NICHE PROBLEM>
>>
>>60436908
I don't understand what is supposed to be so difficult about this problem. Isn't it just:
void busybeaver(unsigned char const* address, int size) {
for (; size > 0; size--, address++) *address = 0xff;
}
>>
>>60436527
Am I the only one underwhelmed by all of this?
Why doesn't the compiler do this at compiletime?
Most compilers aren't even competently multithreaded. This is the perfect kind of workload. It's easy to prove that no input can affect the result so just run it. Set a cap on the number of CPU ticks you can waste if you're concerned about halting. Send a warning to the user that they failed to optimize it and cache the result for next compilation.
The user was asking for -O2. Why is it not optimizing?
>>
>>60435466
C# it is
>>
>>60437010
>niche
>one of the most famous examples of a non-computable function that any undergrad who has enough brain cells to be able to take an intro to complexity course would encounter
This Pajeet damage control is just hilarious.
>>
>>60437020
shit why did i put const there
>>
>>60437026
>CLR
It was covered.
>>
>>60436984
you what... why isn't everyone using the same programming language then, seeing as most mainstream ones (and even niche ones like haskell) mostly have every single thing you might want already implemented in some library?
>>
File: fellel.jpg (83KB, 1280x696px) Image search: [Google]
fellel.jpg
83KB, 1280x696px
>>60435343
>C/C++ bloated
>test.class only 463 bytes
you forgot to add the 6000 kb for the java virtual machine
>>
>>60437048

That would still add up to less than the others
>>
>>60436951
>rubyist@Overmind
>not root@ambrozia
>>
>>60437048
what the fuck is this meme about needing some huge ass virtual machine to run java? java compiles to native bytecode you absolute retards
>>
>>60437072
>native
>bytecode

yup, java pajeet, makes sense
>>
>>60437022

Compiler isn't going to evaluate a large enough loop, as long compile times are not desirable. It also isn't smart enough to know that it could solve the entire problem in a single div instruction. Hence, it generates the loop, but does regular optimizations, like converting division into other instructions.
>>
>>60437061
>6000kB+x <9.1kB
What?
That sounds like a rather conservative measure given the size of Java installations I've had. But I don't know how big it actually is.
>>60437072
>bytecode
Sure, Java can compile to a binary for the platform. Most languages have something like that. What's being compared is the more normal running modes.
>>
>>60437088
you know what i mean. point is, .class files are just executable files like any other, they consist of machine instructions for whatever processor you compiled on and don't require any virtual machine to run
>>
>>60437096
>as long compile times are not desirable
Every compiler should have a flag that tells it I don't care about this.
But it's very annoying to have a program that can be run in less than 10 seconds be compiled into such an inefficient piece of code.
>>
>>60436383
>>60436886
Just also tried it in the Julia repl:
function main()
n = 0
for i = 1:2000000000
if (i%3==0 && i%5==0) n = n + 1
end
print(n)
end


Running this in the repl with the @time macro gives me 3879 ms

So faster than C/Java/Rust, despite the fact that the language is dynamic, and that this includes the jit compilation time. I'm spooked.

Python has no excuse whatsoever to take several minutes to finish this task.
>>
>>60437114
>.class files are just executable files like any other
Rename it and run it.
Protip:
Doesn't work like that.
>>
>>60437142

What? C was doing it in less than 2 and java was doing it in 2.2. 3.9 is nowhere near
>>
>>60436908
what's so difficult about 1-filling a bitfield
>>
>>60437168
I quoted my earlier tests on the same machine. Can't tell if troll or retard.
>>
File: pls.jpg (49KB, 331x331px) Image search: [Google]
pls.jpg
49KB, 331x331px
>>60436659
>>
>>60437184

Well then you're a lyin bastard because that's clearly interpreter propaganda
>>
I wonder how you could write a compiler that knows to optimise things like that where a loop isn't really needed.
>>
>>60437217
most compilers will optimize away loops like
for (int i = 0; i < 100000000000; i++) {}
>>
>>60437217
It's not particularly hard. It's just that cases like these aren't a big concern.
>>
>>60437226

I know that but I mean like calculations that can be done in one step instead of by going through every number in a loop
>>
>>60437142
Also if you are copypasting this it should have "end" at the end of the inline if.
>>
>>60437142
All hail the LLVM JIT. That thing is a beast.
>>
File: 1494945406530.png (151KB, 1654x1116px) Image search: [Google]
1494945406530.png
151KB, 1654x1116px
Friendly reminder that Rust is actually lighter weight than both C and C++.
>>
>>60437334
It's shit. Fuck off.
>>
>>60437347
>Damage control
>>
>>60437387
>Damage cunttroll
ftfy
>>
What's wrong with Python? Why does /dpt/ hate it so much?
>>
>>60437429
it bad
>>
File: java troll.png (46KB, 1050x750px) Image search: [Google]
java troll.png
46KB, 1050x750px
>>60435343
>>
>>60437142
The function call compiles to some rather tight assembly:

        pushq   %rbp
movq %rsp, %rbp
movl $1, %ecx
xorl %r8d, %r8d
Source line: 4
movabsq $6148914691236517206, %r9 # imm = 0x5555555555555556
movabsq $7378697629483820647, %r10 # imm = 0x6666666666666667
L32:
movq %rcx, %rax
imulq %r9
movq %rdx, %rax
shrq $63, %rax
addq %rdx, %rax
leaq (%rax,%rax,2), %rax
cmpq %rax, %rcx
jne L85
movq %rcx, %rax
imulq %r10
movq %rdx, %rax
shrq $63, %rax
sarq %rdx
addq %rax, %rdx
leaq (%rdx,%rdx,4), %rax
cmpq %rax, %rcx
je L99
Source line: 3
L85:
incq %rcx
cmpq $2000000001, %rcx # imm = 0x77359401
jne L32
jmp L115
Source line: 4
L99:
incq %r8
Source line: 3
cmpq $2000000000, %rcx # imm = 0x77359400
leaq 1(%rcx), %rcx
jne L32
Source line: 6
L115:
movq %r8, %rax
popq %rbp
retq
nopl (%rax,%rax)
>>
>>60437142
Gotta try it in Common Lisp next. Dynamic languages with proper compilers FTW.
>>
>>60437429
>dynamically typed languages
>>
>see this

} catch (Exception ex) {
throw new RuntimeException(ex);
}


What do?
>>
>>60437114
>This is the average Java programmer
>>
>>60437429
Because it doesn't look cool.
>>
>>60437542
Remove it and carry on.
>>
>>60437142
$ cat main.c 
#include <stdio.h>

int main()
{
int n = 0;
for (int i = 0; i < 2000000000; ++i) {
if (i % 3 == 0 && i % 5 == 0) {
++n;
}
}

printf("%d\n", n);

return 0;
}
$ gcc -O2 -Wall -Wextra -Werror -pedantic main.c
$ time ./a.out
133333334

real 0m2.028s
user 0m2.025s
sys 0m0.001s
>>
>>60437686
Cool. Now install Julia and try out this code:

>> function main()
n = 0
for i = 1:2000000000
if (i%3==0 && i%5==0) n = n + 1 end
end
print(n)
end

>> @time main()


on the same machine if you want to compare the two.
>>
Any suggestions to my Fizzbuzz?
#include <stdbool.h>
#include <stdint.h>

void function_104(int32_t a1, int32_t a2);
void function_11a(int32_t a1);
int32_t function_11f(int32_t a1);
void function_8a(int32_t a1, int32_t a2);
void function_c7(int32_t a1, int32_t a2);
void function_e(int32_t a1, int32_t a2);
bool g1 = false;
int32_t g2 = 0;
int32_t g3;

int main(int argc, char ** argv) {
int32_t v1;
g2 = &v1;
int32_t v2;
function_e(v2, 0);
return g1;
}

void function_e(int32_t a1, int32_t a2) {
int32_t v1;
function_11f(v1);
g1 = true;
function_8a((int32_t)&g3, 1);
}

void function_8a(int32_t a1, int32_t a2) {
int32_t v1;
function_11a(v1);
}

void function_c7(int32_t a1, int32_t a2) {
int32_t v1;
function_11a(v1);
}

void function_104(int32_t a1, int32_t a2) {
int32_t v1;
function_11a(v1);
}

void function_11a(int32_t a1) {
return;
}

int32_t function_11f(int32_t a1) {
return 0;
}
>>
>>60437429
it's too plain. doesn't offer anything special versus other similar languages (Ruby, Perl, Scheme). has no compelling features
>>
>>60437429
It's popular and it is only getting more important despite being slow as fuck. Also the python community is insanely toxic. Ask a python programmer for help on a project and 90% of the time they will ignore your question and instead insult your code for not being "pythonic" enough.
>>
>>60437824
you shouldn't ask for help on obfuscated code
>>
>>60437824
>int argc, char ** argv
>>
>>60437593
Are you saying the average Java programmer is right about things?

Because I'm inclined to agree with that.
>>
>>60437824
You can improve this. Write a brainfuck to C translator. Then compile a brainfuck hello world program to C.
>>
>>60437965
You are honestly brain damaged if you actually think that what >>60437114 said is true.
>>
>>60437824
Are you indian or something?
>>
>>60438077
I am that person, and what I said IS true. You can just run a .class file as a standalone. I don't even have the JVM installed.
>>
I have 0 experience with android
is it hard to make a custom rom? I just want 4.4 on my 4.2 tablet to be able to run new apps
>>
>>60437879
>Python designed for "there's only one way to do the job"
>your code is not pythonic
>>
File: 2017-05-17-120755_644x388_scrot.png (11KB, 644x388px) Image search: [Google]
2017-05-17-120755_644x388_scrot.png
11KB, 644x388px
>>60438121
Sure thing, bud.
>>
>>60438164
you're fucking retarded mate
>>
Which should I learn next of these?

>Haskell
>Idris
>Scheme
>Rust
>>
File: program.png (88KB, 1287x659px) Image search: [Google]
program.png
88KB, 1287x659px
So I took a different approach to learning how to program than python. I read a book on logic, pseudocode, conventions, and flowcharting and then another on VB and visual studio. I just finished them and made my first like full program.
It's a little database system, about 500 lines of code. There are 5 options CPU, GPU, SSD, RAM, PSU that launch a window with a table of parts and you can add more ifi you want. Then there is a parts list that lets you select parts, add them to a list, and save the list or open one you made previously. Also have a resources menu that opens websites like toms hardware and newegg in your browser.
I'd upload it but I'm sure no one would run a random exe from some nigger. It's awesome, I feel like I can actually do something and I've only been working at it for like 4 months.
Anyone who wants to try and learn I really suggest you read a book on logic and good practices before picking up a language.
>>
good vid on AVL's
https://www.youtube.com/watch?v=eAI-P_6ydds
>>
>>60438217
Please tell me how to run a java .class "directly" without the JVM.
>>
>>60438236
In this order

1. Haskell
2. Idris
3. Haskell
4. (Sch/M)eme
>>
>>60438265
Solaris
>>
>>60438164
>>60438265
Holy shit are you actually this stupid?
What did you think the JVM even existed for?
To look pretty?
>>
>>60438265
you can't. you can't run Java programs without a JVM unless you compile them to native code
>>
>>60438306
All you need is a chip that runs Java bytecode.
>>
>>60438265
You've been played like a fucking fiddle m9
>>
ATTENTION /DPT/

There's no longer any need to write Java or Scala.

https://github.com/mmhelloworld/idris-jvm

JAVA CHECKT, KEKT, AND REKT
>>
>>60438405
>idris
yes there is
>>
>>60438345
Genera Type Erasure :^)
>>
>>60438440
C is a poo language
>>
>>60438428
Still upset that I wouldn't give you a copy of the book?
>>
>>60438471
All functional languages are poo languages.
OOP languages are even worse, but that's no reason to use a functional language over an OOP language because you shouldn't be using either, ever.
>>
>>60438485
Still proud of understanding pointers and nothing else? Or are you the data-oriented memester?
>>
>>60438503
Data-oriented programming is even worse. And I wouldn't dare touch a language that has """""pointers""""".

Don't even get me STARTED on Web """""""""""""""""""""""""""programming""""""""""""""""""""""""""". Or [cringe] ASSEMBLY.
>>
>>60438514
Ah, I understand now. You're one of the rarest posters on /dpt/: the poster who can't program at all.
>>
>>60438539
No, I'm an even rarer breed around these parts.

The god damn fucking troll.

Get rekt, I've been bullshitting this whole time. Scheme is my favorite language, but I also like Lisp, Haskell, C, C++, Java, Python, Ruby, and the web languages.
>>
>>60438564
>Scheme is my favorite language
Then I truly pity you.
>>
>>60438471
what book
>>
>>60438578
But it's a good language though.
You seem to be implying it isn't, but you'd be wrong to imply as much, because actually it is.
>>
>>60438457
yes?
>>
>>60438347
>>60438306
>>60438291
I fucking know you can't do this. I was purposely following the other anon's stupid statement, showing that it doesn't work.

>>60438275
I thought someone might bring that crap up.
>>
>>60438604
yes?
>>
>>60438614
>I fucking know you can't do this. I was purposely following the other anon's stupid statement, showing that it doesn't work.
I know you were. But the point is it looked like you might not have been. Therefore you've been played.
>>
>>60438597
Oh, it's better than most of the others you listed, no doubt. But it's a bit like somebody saying their favorite food is plain rice, it's better than dog turds but it shows that they have no taste.
>>
>>60438633
Better languages don't exist. (By the way, not being viable for professional use counts as not existing.)
>>
>>60438643
>not being viable for professional use counts as not existing
Then Scheme doesn't exist.
>>
>>60438614
>I thought someone might bring that crap up.
>I thought someone might bring up an argument I can't refute!
>>
>>60438673
Solaris has the JVM, though, so anon's statement is still wrong.
>>
>>60438659
Shit that's true.
In that case, my favorite language that exists is Ruby. I just wish it were compiled and/or not slow as balls.
>>
>>60438687
I think my favorite language that exists might be Java, at least I can write it mostly on autopilot and get my IDE to write most of the code for me.
>>
I'm trying to beat https://alexnisnevich.github.io/untrusted/

You guys should try it. A puzzle game you must solve by modifying it's code.
>>
Why do corps keep coming up with new languages? Swift, Go, Rust

Assuming that corporations aren't physically capable of making anything beneficial to humanity, what's their endgame?

Power moves? Trying to lower field entry threshold to increase profits?
>>
Hey I have a module in Python containing functions and two global vars

And I made a script that uses this module and vars
aka
 from module import * 


If I paste the script into the module (and import argparse in the module), it works perfectly

If I use the script separately, it doesn't behave well (the module appears to be reading the vars from its own scope)

The variables from the module are changed as wanted, I tried to import it in REPL and it worked, but still didn't behave well (it's completely fucked I don't get it)

wat do
>>
>>60437114

>.class files are just executable files like any other
No. They are a format unto their own. They don't even start with the same magic number as any standard executable format, like ELF, PE/COFF, or Mach-O.

Magic numbers:
Java .class file: CA FE BA BE.
ELF: 7F 45 4C 46 (note: last three bytes spell out ELF in ASCII).
PE/COFF: 4D 5A (note: this is MZ in ASCII, the initials of one of the MS DOS developers).
Mach-O: FE ED FA CE, or FE ED FA CF for 64-bit platforms. This is reversed on little endian platforms.

>they consist of machine instructions for whatever processor you compiled on
The reason why Java is so portable is that it doesn't generally compile to machine code, at least not ahead of time. Those instructions in your .class file are actually a format of their own, consisting of mostly single byte instructions that manipulate a stack.

https://en.wikipedia.org/wiki/Java_bytecode

Native code execution does not occur until this file is loaded by the Java Virtual Machine and JIT compiled into native code.

> and don't require any virtual machine to run
While it is possible to compile Java source files into native ELF or PE/COFF, the .class files generated by javac are only able to be run by the Java Virtual Machine. No OS can understand them natively, and no CPU can understand the instructions.
>>
>>60435610
>Thank you for using an anime image.
that's manga faggot
>>
>>60438917
Each of those languages was created for a different purpose.
>>
who here works at google and makes 200k/year like me?
>>
>>60438951
Nobody, not even you.
>>
>>60438951
Nobody. Not even the people working at google.
>>
>>60438922
ok I set the values I wanted directly in the vars in the module (instead of from the script) and it worked

so the problem definitely is that my script doesn't send values to the module's vars

please help
>>
>>60439054
You are importing it wrong then
Also modules should be used like modules. You are not supposed to transfer information between your main program and modules.
>>
>>60438955
>>60439045
A senior SDE at Google makes an average of $210,865, that's possible 10~ years out of college.
>>
>>60439137
yeah but my module uses parameters that are variables

aka if statements with vars
that are set in the module as None (to be initialized)
that are set later in the script as an argument on the command line

I mean I can't transfer parameters to modules ? that's retarded
>>
>>60439164
that's about $20.000 a year if you factor in silicon valley cost of living though.
>>
>>60439164
>A senior SDE at Google
i.e. not you
>>
>>60439173
Modules are meant to be modular. Your module shouldn't be taking in and remembering variables. Initialized those variables when you call the functions from the module.
>>
What are some good resources for learning SDL in C? I am using a unix environment.
>>
>>60439179
>.
Wew, Europe.
>>
what is python and what does it have over lua or squirrel for game scripting?

is it as easy to port to a console as lua?
>>
in the module I have

        if global2 == "keyword1" and var.lower() in global1:
pass
elif global2 == "keyword2" and var.lower() not in global1:
pass


and in the script

if args.arg1:
global1 = func1("file1")
if global1 is None:
global2 = None
else:
global2 = "VALUE1"
func2(args.arg3, {})

elif args.arg2:
global1 = func1("file2")
if global1 is None:
global2 = None
else:
global2 = "VALUE2"
func2(args.arg3, {})

else:
func2(args.arg3, {})


I don't see how I could do this without variables
>>
>>60439240
$20 is a lot of money in east europe
>>
>>60439302
Le wannabe gamedev faec
>>
>>60439228
>SDL
>C

mein negroft

the lazyfoo tutorials would be good to look at, but its alot of work to unfuck the c++ code he has interwoven
>>
>>60439308
I don't see any information transfer from module to script or vice versa.
>>
>>60439341
well global1 and global2 are defined the module as None

and they stay that way so my script will only run the last else statement
>>
>>60439355
in the module*
>>
>>60439355
>>60439367
That is not how modules are supposed to work friendo. Why don't you just write functions and don't import modules. That way you can keep all the variables you want in one place.
>>
>>60439382
because modularization
>>
>>60439391
Sure. You seems like you have programmed in python before. Aside from your own modules, have you ever came across a python library or module that takes and stores variables which change the way the module works?
>>
>>60439431
nah
it's ok I did it, modified the functions in the module to take two more arguments and passed the values as arguments
thanks lad
>>
>>60439530
That is the proper way to use modules btw. Your modules and libraries aren't meant to store information from your main program. Any information they need should be passed onto them, processed and then returned.
>>
>>60439624
yeah I've been working on this shit for 16 hours straight I guess I was hoping for an easy way, didn't want to bug my functions by modifying their structure of something

off to sleep now I guess
>>
Don't you guys have a guide or something?

I want to get started on python but I want the /g/ official guide instead of starting random tutorials on the internet.

Also new to programming so I want something for someone with a mathematical background to get into programming preferably also skipping the children level "hello world" sections.
>>
>>60439773
There is no "official" /g/ guide to programming. There is no way is hell that /dpt/ or /g/ as a whole would come to any sort of consensus. That's why there are intentionally no resources listed in the OP.
>>
>>60439773
>I want to get started on python
Getting drunk is a more fruitful way of killing brain cells.
>>
>>60439773
Python is simple enough any guide will do.
Also don't skip the hello world sections because practicing them drill the syntax and structure into you.
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!
>>
>>60439956
At least D isn't as bad as Go
>>
>>60439973
Go GC is better
>>
>>60440002
>>60439956
>GC
And that's why both of those languages are complete jokes.
>>
>>60436004
dumb frogposter
>>
>>60440002
PROTIP: focusing on pause times at the expense of everything else means Go's GC is worse at everything else.
>>
>>60440016
why don't you code in C/C++/Rust if you don't want a GC, a GC is fine for many applications
>>
>>60440053
I _do_ program primarily in C.
>>
File: beeb32bb1ce7023445d8cfc80a0a5496.jpg (695KB, 1090x1180px) Image search: [Google]
beeb32bb1ce7023445d8cfc80a0a5496.jpg
695KB, 1090x1180px
>>60440002
Go's GC is shit, and they know it.

>>60440016
>And that's why both of those languages are complete jokes
GC's are inherently bad. It depends on the software being made and how it's used. For example, making a text editor that runs on your standard desktop system can get away with any performance issues a GC can cause. On the other hand, any program that performances an real-time networking needs to be optimized as fuck and know when shit's going to be free'd or allocated. Though in that case you'd have a memory pool.

>>60440092
>_do_
>__
Faggot.
>>
>>60440119
>GC's are inherently bad.
I meant to say
>GC's aren't inherently bad.
Fuck.
>>
I started learning go for writing server code and APIs.

Have I made a mistake? Should I be using something else instead? Elixir or Clojure?
>>
>>60440119
>Not knowing that _word_ is used for emphasis
Fag.
>>
>>60440161
you're fine

though I would like to try elixir sometime
>>
>>60440218
But it's *not*.
>>
File: 1438749590433.png (94KB, 400x400px) Image search: [Google]
1438749590433.png
94KB, 400x400px
>>60440218
The implication there was that you're a faggot for using unsupported markup; which you are, you vagina-loving faggot.
>>
>>60440227
Fine, lets just go with the \latex version \emph{instead}.
>>
>>60440258
>vagina-loving faggot
Explain.
>>
>>60440258

>Not loving vaginas
But they taste so good, Anon...
>>
>>60440346
Did you find a way to taste your own or something? Fucking disgusting.
>>
>>60440363

I've only tasted one vagina -- my ex-girlfriend's. Nonetheless, it tasted pretty nice. Also, I have a penis, not a vagina.
>>
>>60440375
>I have a penis, not a vagina.
Filthy lies
>>
>>60440325
Anything but futa lolis is gay as hell, anon. It's /g/ and /dpt/ 101.

>>60440346
>Ruby
>tasting vagina
Lesbians are not welcome here. Please leave.
>>
>>60436375
That Sudoku puzzle is already wrong.
>>
>>60440388
>>60440484

Sorry, /g/entlemen, but I'm a dude. You know the rules: there are no girls on the Internet.
>>
>>60440928
>there are no girls on the Internet.
You're such an old woman, Ruby. That rule is so last century.
>>
>>60440938

It was around when I was on 4chan in 2006, and as far as I'm concerned, the rules of the Internet are eternal.
>>
File: 1491686736920.jpg (4MB, 2877x3246px) Image search: [Google]
1491686736920.jpg
4MB, 2877x3246px
>>60440928
/g/ is exclusively for tech-literate lolis. Get out of here oba-san.
>>
>>60440991
Who the fuck are you calling a babaa you cunt?
>>
File: 1452400077466.jpg (38KB, 640x480px) Image search: [Google]
1452400077466.jpg
38KB, 640x480px
>>60441011
>babaa
I addressed her politely unlike you, slut.
>>
>>60441328
inb4 >i told you so

ifThenElse b t f = if b then t else f
>>
>>60441337
This will only work in a lazy language
>>
File: cute boy awoo.jpg (151KB, 645x989px) Image search: [Google]
cute boy awoo.jpg
151KB, 645x989px
Is there a good resource on writing posix compatible shell scripts so I can avoid bashisms?
>>
Someone is bullying my sieve: Give it to me straight, /dpt/, how bad is it? >>60439316
>>
Trying to learn python
>>
>>60441436
It won't work at all
>>
>>60441501
>python
Pretty bad
>>
File: 1368226600535.gif (2MB, 240x180px) Image search: [Google]
1368226600535.gif
2MB, 240x180px
>can program a sieve of eratosthenes in <5 lines in lisp, not a big deal
>have spent the entire afternoon trying to get it done in C++
What the fuck? I feel like I'm fighting this language every step of the way. This isn't even a hard exercise, I just can't get a handle on how to make it work in this language.
>>
>>60441501
Rewrite it in Lisp.
>>
>>60441501
It's okay. There are better. Give me a minute and I'll post mine.
>>
>>60441527
Just write it in C, it took me 10 minutes and it's bitpacked for 16x memory savings.
>>
I made a dumb little simulation of the monty hall problem in ruby a few years ago because I'm stupid and don't get why the chances are better if you switch. but lo and behold it's very consistent in that switching is a lot better than staying. but what I want to know is if I can use a better random number thing than ruby's rand function and import it into ruby somehow. or if it would even actually matter and ruby's is good enough.
>>
>>60441529
What is the runtime for an average trivially optimized sieve in Lisp for a limit under 2 million? I.e. time to sum primes under 2 million.
>>
>>60441555
When you select the first door there is a 2/3rds chance you picked the goat. How is this hard to understand.
>>
>>60441660
forget about that, why does the universe care what you picked already

it's like how people say that the odds of flipping a heads 20 times in a row are really small. I dont get that. the odds of flipping heads are 1/2. that doesn't change when you flip the coin again, it stays fucking 1/2, what is the force that cares what you did before, why is that relevant
>>
>>60441660
you pick a door, the host opens up a goat door, so you're presented with 2 doors. one with a goat and one with a car. how the FUCK is that not 1/2 and why does it matter what the hell happened before this situation?
>>
>>60441527
std::array<bool> arr(100);
arr.fill(true);
for(int i = 2; i < arr.size(); i++)
if(arr[i])
for(int j = i*2; j < arr.size(); j+=i)
arr[j] = false;

Or something like this, didn't care to check
>>
>>60441705
Take out a piece of paper and write down all the possibilities. Initially, it can be in one of three states.
CAR  GOAT GOAT
or
GOAT CAR GOAT
or
GOAT GOAT CAR


You pick door 1. Now let's go through every possibility if you say switch.
1. You picked a goat. He reveals a goat (door 2). You switch. You get the car.
2. You picked a goat. he reveals a goat (door 3). You switch. You get the car.
3. You picked the car. He reveals a goat (door 2). You switch. You get the goat.

You win 2/3rds of the time.

Now the opposite, still selecting door one.
1. You picked a goat. He reveals a goat (door 2). You stay. You get a goat.
2. You picked a goat. He reveals a goat (door 3). You stay. You get a goat.
3. You picked the car. he reveals a goat (door 2). You stay. You get a car.

You win 1/3 of the time.

Switching will always reverse your odds.

What if there were 100 doors, and after you picked one, he opened 98, all with goats. Would you switch then?
>>
>>60441600
I don't feel like writing one at the moment, but the version on rosetta code runs in 0.107 seconds on my computer (thinkpad T410).
>>
>>60441705
>>60441734
not him, but suppose there are 500 doors instead of 3.

>you pick one at random
>host opens 498 doors with goats in them

where do you think the car is more likely to be, your initial guess or whichever door the host skips?

the three-door game works the same way
>>
File: yukari_yes.png (144KB, 640x360px) Image search: [Google]
yukari_yes.png
144KB, 640x360px
>>60441527
>mfw too intelligent to code in one of the most easy and entry level languages in the world
>>
>>60441777
>>60441787
I don't care if there were 100 or 500 doors.

if I presented you, RIGHT NOW, with 2 doors, one with a goat and and one with car, does it matter what you pick? no, you're equally likely to get either.
now imagine that after you picked the door but before it was opened for you, I manifested another door, and told you it had a goat behind it. you'd probably be incredulous and wonder why the fuck I brought in this 3rd door with a goat when you're obviously not going to pick it.
>>
>>60441867
There's a subtle difference

In the original example, you are given THREE doors and the car can be in ANY of those three doors.

In your example, you are given TWO doors, and the car can be in either of the two doors, and the third door is extraneous because the host shows you it's a goat anyways. Yeah, this example has a 50% chance of getting a car, but that's only because you KNOW at the beginning the car will only be in one door or the either, but the original scenario has it where the car can be in any of THREE doors.
>>
>>60441867
The problem is that your intuition about the problem is wrong. The trick in switching, is that when you switch doors you end up with odds equal to your 1 - initial probability of picking the car.

With three doors, there is a 1/3rd chance I picked the car, so if I switch I a ultimately have a 2/3rd chance of picking the car.

With one hundred doors, there is a 1/100 chance I picked the car. If I switch, I have a 99/100 chance.

If you start with 2 doors, there is a 1/2 chance of picking the car initially. Adding a door with a goat after I have picked does jack all to that chance.
>>
>>60441895
>In the original example, you are given THREE doors and the car can be in ANY of those three doors.
but then the host reveals a goat door, and it's the same as being given 2 doors, and the car can be in either of the 2 doors
>>
File: dfgdfgdfgdfg.png (452KB, 1132x911px) Image search: [Google]
dfgdfgdfgdfg.png
452KB, 1132x911px
I keep seeing people complaining about lack of an archive.is for youtube, and youtube has stripped a lot of people of ad revenue lately because libs made a fuss, so I made this little thing. You can share any youtube video without giving the video a single view or any ad revenue. All you have to do is rewrite the youtube domain to this domain and it works right away. It's based on streaming the mp4 etc directly in a html5 player.

Just need to decide on a domain. The one in the picture is cool and short but costs $390 dollarinos a year.
>>
>>60441944
>All you have to do is rewrite the youtube domain to this domain

I worded that badly, it's not live until I make the domain decision
>>
If you picked a goat, switching always wins a car.

If you picked a car, switching always wins a goat.

You have a 2/3 chance to pick a goat.
>>
>>60441941
but the host won't always reveal the same door for the goat

Say door A has goat, door B has car, and door C has goat

If you choose door A, host will open door C
If you choose door C, host will open door A
If you choose door B (car), host will open either A or C

It's not a particular door set in stone
>>
>>60441944
before I read your post I just looked at the pic and my first thought was that it looked like some weird trashy scam shit, even if it works fine. yt.lol is a terrible domain name and that logo is shit
>>
>>60441538
>>60441501
It's an infinite generator of primes. Sum of prime numbers under 2e6 take 0.8s on my T420 (powersave governor).
from itertools import compress, count, cycle

def primes():
yield from (2, 3, 5)
wheel = [1, 7, 11, 13, 17, 19, 23, 29]
yield from wheel[1:]
wheelcheck = frozenset(wheel)
selectors = (1 if x in wheelcheck else 0 for x in range(30))
next_check = {x*x:x for x in wheel[1:]}
for i in compress(count(30),cycle(selectors)):
if i in next_check:
prime_root = next_check[i]
del next_check[i]
trial = i + 2*prime_root
while trial in next_check or (trial % 30) not in wheelcheck:
trial += 2*prime_root
next_check[trial] = prime_root
else:
next_check[i*i] = i
yield i
>>
>>60441962
this could make you a lot of shekels lad, especially if some controversy happens
>>
File: 1494064327567.png (335KB, 457x380px) Image search: [Google]
1494064327567.png
335KB, 457x380px
>>60441866
I just keep trying to rely on facilities the language doesn't have. In lisp the sieve is a single for/fold expression over an empty sequence and a sequence or generator of integers. You just fold the generator or sequence into the empty one, dropping elements that are multiples of previous elements. I finally found a solution but it's a completely counter-intuitive one that involves using a for-loop over a vector of integers and setting those that are multiples of the value at the previous index to zero and pushing non-zero values to another vector. It feels really obtuse.
(define (eratosthenes n)
(for*/fold ([primes (range 2 (add1 n) 1)])
([candidate (range 2 (add1 n) 1)]
[composite (range (* 2 candidate) (add1 n) candidate)])
(remv composite primes)))

Makes total sense to me and "feels like" it's described in terms of the problem. I don't have to worry about vectors or arrays of memory, or whether an element is a iterator indicating the last element of the vector or the element contained at the last point, etc. I don't know where the "lisp is hard" meme came from because it it feels infinitely easier to program in lisp than C++ so far.
>>
>>60441977
And then there's the fact that's associated with /pol/
>>
>>60441944

www.fuckyoutube.com, then you only need to add "fuck" to the URL. Screw might also work and sound a little better.
>>
>>60441977
Got any suggestions for domains that could fit the purpose? I considered stripped.tube but it's a little long.

re: logo it's just some text and css, fuck adding extra hits on the server if you don't need to
>>
>>60442013
this is pretty good
i just went to it though and it immediately closed, I will assume adblocker caught a popup so I guess someone already owns it
>>
>>60442016
boipucci.edu
>>
Reimplemented bitset in Rust. Sadly, generics can't take integer arguments, so I can't do this with a fixed sized array. Also, can't implement Index or IndexMut trait because they are required to return a reference.

pub struct BitVector {
size: usize,
bits: Vec<u32>
}

impl BitVector {
pub fn new(size: usize) -> BitVector {
BitVector {
size: size,
bits: vec![0u32; (size / 32) + 1]
}
}

pub fn get(&self, index: usize) -> bool {
if index > self.size { panic!("Index out of bounds!"); }
self.bits[index / 32] & (1 << (index % 32)) == 1
}

pub fn set(&mut self, index: usize) {
if index > self.size { panic!("Index out of bounds!"); }
self.bits[index / 32] |= 1 << (index % 32)
}

pub fn clear(&mut self, index: usize) {
if index > self.size { panic!("Index out of bounds!"); }
self.bits[index / 32] &= !(1 << (index % 32))
}

pub fn toggle(&mut self, index: usize) {
if index > self.size { panic!("Index out of bounds!"); }
self.bits[index / 32] ^= 1 << (index % 32)
}
}


>>60441555

When you initially picked a door, the door had a 1/3 probability of containing a car. This never changes. What does change is your knowledge of the available doors, because Monty MUST pick a door containing a goat. You know there is an equal probability that the goat is behind door 1, 2, or 3. If it's behind door 1, Monty can pick whatever he wants of the remaining doors. But this only has a 1/3 chance. In the remaining 2 cases, Monty must pick the door that does not contain the car. Therefore, switching guarantees you a car in both of those cases.
>>
>>60441944
Neat idea.
I have a few channels I want to "subscribe" to, so what I do is have a text file with the channel name as the file name and the content is all the videos I have watched from the channel.
Then I loop through all the channels and download the new videos I haven't watched.
>>
>>60442025

fuckyoutu.be
>>
>>60442053
Ah, that's a good idea. I'm a fellow can't subscribe cause I don't use google accounts guy and I have a computer dedicated to running bots any way.
>>
>>60441969
It doesn't matter. In your example if you pick A host opens C and switching wins the car. If you pick C host opens A and switching wins the car. If you pick B host opens either A or C and switching loses. Given the three initial choices of door, two of them result in switch-to-win, one results in switch-to-lose. Switching > sticking.
>>
>>60441988
I particularly like the generator form. Prime-based mathematical utilities become easier to implement.

def is_prime(n):
sqrt_n = sqrt(n)
return not any((n % p == 0 for p in takewhile(lambda x: x < sqrt_n, primes())))

def decompose(n):
if n <= 1:
raise
for p in primes():
if p*p > n: break
while n % p == 0:
n //=p
yield p
if n > 1:
yield n

def factorize(n):
if n == 1:
yield 1
elif n < 0:
raise
else:
# get prime factorization of n and make parallel list of divisors and powers of the respective divisors
divisors = []
powers = []
for d, p in Counter(decompose(n)).items():
divisors.append(d)
powers.append(p)
# permute all the powers, apply the powers to their respective divisors, yield the total product
for perm_of_powers in product(*map(lambda p: range(p+1), powers)):
yield reduce(operator.mul, [d**p for (d, p) in zip(divisors, perm_of_powers)])
>>
>>60435165
Please don't use /prague/ pictures on /g/.
>>
Anyone got a good guide for rust-sdl2 that is v0.30 yet? I know it's kinda early yet but I don't understand lifetimes and I want to be spoonfed
>>
>>60442171

Wouldn't this also mean that the more doors there are to begin with (and eliminated until there's only two left), the higher your odds would be at the end? That just can't be right.

100 doors, eliminate 98, be offered to switch -> 99% chance of winning?
>>
>>60442172
def factorize(n):
if n == 1:
yield 1
elif n < 0:
raise
else:
# get prime factorization of n and make parallel list of divisors and powers of the respective divisors
(divisors, powers) = zip(*Counter(decompose(n)).items())
# permute all the powers, apply the powers to their respective divisors, yield the total product
for perm_of_powers in product(*map(lambda p: range(p+1), powers)):
yield reduce(operator.mul, [d**p for (d, p) in zip(divisors, perm_of_powers)])
>>
>>60438347
>I was just pretending to be retarded
Oh, there's no way anyone is going to believe that anon. Java people are certainly so stupid they'd say stuff like this.
>>
>>60437534
>dynamically typed languages
What's wrong with dynamically typed languages?
>>
>>60442396
Absolutely nothing.
>>
>>60441988
Very neat, especially being an infinite generator and using wheel factorization. I will have to look into the maths behind this, because from the wikipedia page, I had no idea it was so trivial (as in so few LOC). Wheel factorization, in particular, I wasn't able to wrap my head around, while stuff like Miller-Rabin were fairly trivial once read up on, so I'm feeling kinda stupid looking at this.

However, it's significantly slower than my sieve (tested on X220, best of 3).
$ time python3 sieve_of_Eratosthenes2.py 
142913828922

real 0m0.318s
user 0m0.300s
sys 0m0.012s

And
$ time python3 test3.py 
142913828922

real 0m0.655s
user 0m0.648s
sys 0m0.004s

But worst of all, the memory efficiency is outright abysmal. 5+GIB of RAM and growing sieving 2 billion (2e9) before I terminated it. My own sieve uses exactly 981MiB sieving the same, and memory requirements don't change as array is initialized only once. I'm sorry, but I'm not impressed by the implementation.
>>
File: 1479958812243.jpg (19KB, 250x250px) Image search: [Google]
1479958812243.jpg
19KB, 250x250px
>>60435165
Implemented fizzbuzz in my custom language
>>
Do you still have to do manual memory management in C++ :^(

I just want comfy growable arrays
>>
>>60442561
C++ has this in the standard library.
Writing your own vector implementation isn't difficult anyway.
>>
>>60442043
>size: usize,
> bits: Vec<u32>
It's
size :usize
bits :Vec<u32>
>>
why do the makers of clang make it as much of a turn off as they possible can for new people?

from their documentation
>Getting Started Quickly (A Summary)
>1. Read the documentation.
>2. Read the documentation.
The documentation is a non-linear bible filled with thousands of commands that won't make much sense for a new user who hasn't even gotten it started yet
>"Quickly"

is there a guide for retards on how to install and set this up with vim?
>>
>>60442512
Is your language homoiconic?
>>
> What are you working on, /g/?
1. middleware for an LPR reader -> access control system
2. bunch of database tools to extend functionality of closed source alarm monitoring software
3. website/frontend (node/express/hbs) to a bunch of cli tools i've written in the past year

i literally get paid $$$ to fuck around with javascript + sepples and talk shit.

looking for an excuse to use rust because why not
>>
>>60442565
>C++ has this in the standard library.
What do you mean?
Can I simply do array3 = array1+array2?
>>
>>60442581
Nope. C++ is shit.
>>
>>60442598
Dropped
>>
>>60442581
even C has strcat()
also stop concatenating strings with the addition operator, this is JS-tier shit that should have been nipped in the bud 20 years ago
>>
int f(string high, bool inclusive) {
static const char *qq[] = {"00","11","69","88","96"};
int c[27], c0[27];
c[0] = 0; c[1] = 2; c[2] = 4; c[3] = 12;
for (int i = 4; i < 27; i++)
c[i] = c[i-2] * 5;
c0[0] = 1; c0[1] = 3;
for (int i = 2; i < 27; i++)
c0[i] = c0[i-2] * 5;
int n = high.size(), m = (n+1)/2, s = accumulate(c+1, c+n, 0);
string pat(n, '0');
bool f = true;
for (int i = 0; i < m && f; i++) {
f = false;
for (auto q: qq) {
if (n % 2 && i == m-1 && q[0] != q[1])
continue;
if (q[0] != '0' || i) {
if (q[0] < high[i])
s += c0[max(0, n-(i+1)*2)];
if (q[0] == high[i]) {
f = true;
pat[i] = q[0];
pat[n-i-1] = q[1];
}
}
}
}
if (f && (inclusive ? pat <= high : pat < high))
s++;
return s;
}
public:
int strobogrammaticInRange(string low, string high) {
return max(0, f(high, true) - f(low, false) + (low == "0"));
}
>>
>>60442620
Why is + a bad thing?
And what about int arrays?
>>
>>60442561
std::vector<Type> v
>>
>>60442621
What does this do?
>>
>>60442621
Are you a masochist?
>>
>>60442629
That's very Rust-esque of you
>>
>>60442626
+ is the addition operator
you can overload operators in C++, but it's generally poor form outside of well defined mathematical operations such as vector and matrix arithmetic.
>>
>>60442646
>+ is the addition operator
Are you bringing math here? What does >> mean in math?
>>
File: 1489972070805.png (154KB, 383x440px) Image search: [Google]
1489972070805.png
154KB, 383x440px
// Assuming there's a live /dpt/, love (<3) every unique anon in it
foreach (var anon; 4chan.boards[4CH_BOARD_G].thread("/dpt").uniquePosters) {
if (anon.tripcode == "!Sempai.oWA") {
me.bully(anon, assetManager.getRandImgRegex("smug_anime_girl."));
continue;
}

me.cleanSmegma(anon.dick, assetManager.getRandImgRegex("lewd_anime_girl."));
me.suckDick(anon.dick, assetManager.getRandImgRegex("lewd_anime_girl."));
me.drinkCum(anon.dick, assetManager.getRandImgRegex("lewd_anime_girl."));
}
>>
>>60442172
>def is_prime(n):
> sqrt_n = sqrt(n)
This won't handle large numbers, and raise
OverflowError
, e.g. for the 664-digit Mersenne prime 2**2203 - 1. It also doesn't catch even numbers and uselessly checks for primality.
>>
>>60442661
Are there any formal math branches that make use of bitwise shifts?

That's bitwise shift right.
In C++, it means stream input.
>>
>>60442673
Not that I can think of, however >> has a clear meaning in math
>>
File: what_you_see.jpg (1MB, 1600x1200px) Image search: [Google]
what_you_see.jpg
1MB, 1600x1200px
>>60442662
>kommenting your kode
>>
>>60442662
We reached peak degeneracy in this thread boys
>>
>>60442662
Oh, and I typedef my autos. No bully pls.
>>
File: 1493685994252.png (1MB, 1039x988px) Image search: [Google]
1493685994252.png
1MB, 1039x988px
>>60442690
I'm a girl though
>>
>>60442575
no
not yet
>>
>>60442709
wanting to suck people's smegma is not normal even if you're a girl (male)
>>
>>60442251
Yes, that's exactly what it means.

Look at it this way: if there are 100 doors with 99 goats then you have only a 1/100th chance of picking the car right away. 99 times out of 100 you pick a goat, which means that 99 times out of 100 the host reveals 98 other goats and leaves you with the one door that has the car. So there are 99 initial choices of door in which switching wins the car, and just one chance that switching loses you the car. The only way you can lose by switching is if you picked the car right away, which you only had a 1% chance of doing.
>>
File: me_irl29.png (494KB, 454x884px) Image search: [Google]
me_irl29.png
494KB, 454x884px
>>60442723
But stinky cocks are tasty anon
>>
>>60442662
You can find the unique posters on boards without IDs?

Or do you just mean the count of unique posters?
>>
File: average_gentooman.png (60KB, 211x269px) Image search: [Google]
average_gentooman.png
60KB, 211x269px
>>60442723
But that's wrong, anon-kun~~~~~~~~~~
>>
New thread:

>>60442822
>>60442822
>>60442822
>>
>>60435165
>Anime
Hi.
Go to hell.

Are you really THIS stupid mods? I'm immortal.
>>
>>60442775
When
uniquePosters
is initialized, it's filled with each post that, when made, increased the number of IP addresses in the thread from when the thread initialization is done; however, any posts made before the thread initialization are impossible to determine if they are unique. Thus, N number (Where N is the number of unique IP addresses in the thread a the point of initialization.) of the old posts will be chosen randomly in addition to the unique posts made after initialization (if any).
>>
tilde tilde tilde tilde
>>
>>60438583
meme driven development (with Idris)

https://www.manning.com/books/type-driven-development-with-idris
Thread posts: 318
Thread images: 39


[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.