[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 | Extra juicy! | Home]

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: 329
Thread images: 28

File: pair_programming2.jpg (298KB, 800x650px) Image search: [iqdb] [SauceNao] [Google]
pair_programming2.jpg
298KB, 800x650px
/dpt/ [Daily programming] Thread

Pair programming turbo edition.

Old thread is +300: >>51547490

Wat are u working on, anon-chan ?
>>
me on the left
>>
me on the right
>>
>What are the differences?
>Short version: Python 2.x is legacy, Python 3.x is the present and future of the language
>>
>>51557857
Me on the calendar
>>
>>51557857
me me
>>
File: 1422394896484.jpg (740KB, 728x2080px) Image search: [iqdb] [SauceNao] [Google]
1422394896484.jpg
740KB, 728x2080px
>>51557396
rate my superior software engineering skills

(define (podd n)

(define even nn)
(if (< nn n) (odd (+1 nn)))

(define (odd nn)
(display "%d\n" nn)
(even (+1 nn))

(even 0))

(podd 100)
>>
Me on the right poster.
>>
Hey /g/
Just finished making a program that takes lisps as input and spits out all the parens so you can see how fucking retarded it is.
Let's see some examples!:
>>51557954
:~$ ./lolisp gay.lisp
(()()(()(()))(()()(())())()


Another one:
https://raw.githubusercontent.com/dimitri/pgloader/master/src/main.lisp
:~$ ./lolisp main.lisp
()()()()()()(()((())()()()(((())))))(((())(())(())(())(())()()(())(())(()())(())(())(())()(())(())(())(())(())(())(())(())()()))(()(()()))((())((((()))(())(()))(()(()())())))(()((()())(()())()))(()(())(())()(()))()(()((((())))(()())(((())(((()))(())(()())))(()()()(())))))(()((((())((()()))(()))())))(())(()(((()))((())(()))()(())))(()(((()))(()(()(()(())()()))(((()))(()()(())(())(()()))((()((())())))((((()())))(()))()(()())(()(()()))(())(()())(()())((((()())(()(())())))())()((((())(()))(()(())()(((()(()()()()))))(((((()()())))((((()))(()))(())((())(()()))(())))(()()())(()(())())))))()))))(()()(((()))(()())))(()(((())((()()))(((())))(()))()()(((()()(())(()))(()))(()()())(()()))(()(()()()()()()()))))(()(()()())(()()()((((()))(()))(()()()((((()))((((()))(()((()(())((()))))))))(()((())(((())((())))()()()())))(()))(()((())((((()()(()()())))((()()))(()))()()(()(()()())(()()())))))))))((()(())(())(())(()))(()(((((())((()))(((()())()))(((()())(()()()))))))(()))))(()(())((()(()))))(((())(())())(()())((()(())())())((()(()))())((()(()))())(()((((()())))())()((()(((()))(())(())(())(())(())(())(()))))))
>>
>>51558011
>it has lots of parentheses so it must be dumb
>>
>>51558028
This piece of proprietary software does not accept sarcastic criticism. Please cease and desist your paren-fueled rage.
>>
daily reminder that python 2 is superior to 3 in every way and there is no reason or excuse to ever use python 3.
>>
File: 2x.png (460KB, 525x531px) Image search: [iqdb] [SauceNao] [Google]
2x.png
460KB, 525x531px
Faffing about with image resizing. Tried to modify EPX to work for photographs (by having it function on colors that weren't the same, but had a low delta). Results weren't promising so now I'm just doing averages.
>>
Python 3.0 was released in 2008. The final 2.x version 2.7 release came out in mid-2010, with a statement of extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is under active development and has already seen over five years of stable releases, including version 3.3 in 2012 and 3.4 in 2014. This means that all recent standard library improvements, for example, are only available by default in Python 3.x.
>>
>>51558051
python 3 has unicode, async, explicit typing
>>
>>51558074
>>51558078
and anyone worth their salt uses python 2 rather than python 3.
>>
>>51558011
up next: a program that takes an article as input and spits out all the spaces between the words so you can see how fucking retarded it is
>>
>>51557954
data Even : (n : ℕ) → Set
data Odd : (n : ℕ) → Set

data Even where
zeroE : Even zero
sucE : {n : ℕ} → Odd n → Even (suc n)

data Odd where
sucO : {n : ℕ} → Even n → Odd (suc n)

parity : (n : ℕ) → Either (Even n) (Odd n)
parity zero = left zeroE
parity (suc n) = case parity n of λ
{ left even → right (sucO even)
; right odd → left (sucE odd)
}
>>
>>51557857
package main

import (
"fmt"
"net/http"
)

func main() {
resp, err := http.Head("https://www.google.com")
if err == nil {
fmt.Println(resp.Header["Content-Length"][0])
fmt.Println(resp.Header["Content-Type"][0])
}
}

Why is Go so awesome? It's like a scripting language, but strongly typed, faster and more awesome.
>>
<quote>Python 3.x is the present and future of the language
>>
Repostan from previous thread:
Working on a proxy server in python. Thing doesn't work for shit, though. I keep getting
socket.gaierror: [Errno 11004] getaddrinfo failed

Here's the relevant code I've got so far:
#conn is the client's connection.
#request is the request this program received from the client.
#req would later be used for local caching, but for now it does nothing.
req = request.partition(' ')[2]
req = req.partition(' ')[0]
if '//' in req:
port = req.partition('//')[2]
else:
port = req
port = port.partition(':')[2]
port = port.partition(' ')[0]
if port == '' or int(port) == 0:
port = 8080

if req == '':
return
respondDistant(conn, request, int(port))

def respondDistant(conn, req, port):
host = req.partition('Host: ')[2]
host = host.partition('\n')[0]
host = host.replace('www.','')
print host

diffconn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
diffconn.connect((host, int(port)))
diffconn.send(req)

#receiving an answer from the server here, left that bit out


The problem here seems to be the host. Can't figure out what I'm doing wrong, though.
It's not a firewall problem.
>>
>>51558152
>strongly typed
interface{}
>>
are japanese people good at programming?
what do they program over there in japan?
>>
>>51558154
bullshit, python 2 will always be relevant. nobody is going to waste millions so they can port to python 3 when python 2 still exists.
>>
>>51558180
>are japanese people good at programming?

Well, Matz made Ruby, after all.
>>
>>51558190
What relevance does that have when you're starting a new project?
>>
>>51558152
>It has a useful and somewhat expansive standard library, therefor it's a scripting language

Also,
>>51558167
and the reflect library. Total cancer.
>>
>>51558190
well not according to Guido van Rossum
>>
File: guido_no.jpg (84KB, 635x480px) Image search: [iqdb] [SauceNao] [Google]
guido_no.jpg
84KB, 635x480px
>>51558190
Yeah, well, that's just, like, your opinion, man.
>>
>>51558133
Except articles generally have a use.
>>
>>51558203
because you'll start a new project in python 2
>>
>>51558202
So they aren't?
>>
>>51558140
looks like shit t᠎bh
>>
>>51558152
actually, that doesn't work for https://www.google.com , I was testing with another URL...

>>51558167
>>51558205
terrible!
>>
>>51558190
>python 2 still exists
[DEPRECATED]
>>
>>51558222
Why?
>>
>>51558221
>muh brain hurts
>>
>>51558259
why should I start a new project in python 3 when everything works in python 2? don't be dumb.
>>
>>51558152
>It's like a scripting language, but strongly typed, faster and more awesome.
lel, k tard, that sentence doesn't make any sense.
>>
>>51558227

heh
>>
>>51558222
nope
>>
File: 1443062162253.webm (383KB, 416x440px) Image search: [iqdb] [SauceNao] [Google]
1443062162253.webm
383KB, 416x440px
>>51558271
>>
So we went from trap to loli? Nice improvement senpai.
>>
>>51558289
only an idiot would start a project in python 3.
>>
>>51558306
why not use python3
>>
>>51558306
only an idiot would start a project in <meme language>
>>
>>51558271
>everything works in python 2
>what are keyword only arguments
>what is yield from
>what are proper strings
>>
>>51558325
because nobody uses it because lack of package support.
>>
>>51558306
why
>>
>packages from Python 2 don't work in Python 3
Nice job Guido
>>
>>51558306
only a retard would use a deprecated platform
>>
>>51558389
>nobody writes stuff in it because nobody writes stuff in it
m8...
>>
>>51558389
https://python3wos.appspot.com/
>>
>>51558166
host.partition is undefined
>>
>>51558271
>raw_input
>long
>>
File: tfw.png (189KB, 2560x2489px) Image search: [iqdb] [SauceNao] [Google]
tfw.png
189KB, 2560x2489px
>>51558166
TFW no one will answer, ever
>>
>>51558455
Your host is fucking undefined you twat
>>
>>51558455
Fuck off, anon, you're not me. I'm not some dumb frogposter.

>>51558444
What? I don't think it is, anon. I define host by the partitions.
Printing the host says it's correct, in any case.
>>
>Community Web site to promote Python 3
http://getpython3.com/
>>
>>51558568
what a waste of time. python 2 will be used even 10+ years from now.
>>
>>51558592
What satisfaction do you get from this?
>>
Why does /dpt/ consider Rob Pike to be a retard?
>>
>>51558592
applec᠎ucks actually believe this
>>
I'm coming to a hurdle and its really putting a damper in my motivation to learn. I can't seem to grasp GUI design (MVC) at all in JavaFX.. On desktop..

All I've been able to do so far is make a couple stupid command line apps and an android app that used jsoup to grab lotto numbers for the weeks draw from a website(translated from a command line app I made -.-)

Maybe I don't have a good enough grasp on the core language itself yet.. how and why things are used sometimes leave me lost.. Which sends me looking for answers but leads me to more complications and confusion.


Advice, tips? Help..
>>
>>51558610
he's an animu fan, what other proof do you need?
>>
>>51558619
>Advice, tips?
kill -9 self
>>
>>51558610
Because Go. UTF-8 and his work at Bell Labs were praise-worthy, but since he worked at Google he's fell off his rocker.
>>
File: Linus.jpg (125KB, 1211x1210px) Image search: [iqdb] [SauceNao] [Google]
Linus.jpg
125KB, 1211x1210px
>>51558619
>Java
try C# or Swift
>>
Julia is nice. I can pretend I'm using a functional language.
function make_stream(f, acc)
return acc, () -> make_stream(f, f(acc...))
end
stream = make_stream((x, y) -> (y, x + y, (1, 1))
stream[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[2]()[1]
>>
Hi, /g/, I've been awake for almost 3 days now and I need some serious, but easy, logic help.

Here's the deal:
I have one array of 10 positions where the user set the value for each position and I must run it inside a for loop to execute each position for until it's values is equals to 0. But, each position is decreased one time per loop... How do I do this in C?
Here what I've:
int array[9], finished[9], i;
printf("insert values for the array: ");
for(i=0;i<9;i++){
scanf("%i",&array[i]);
}

for(i=0;i<9;i++);{
printf(arra[i]);
array[i]--;

if(array[i]==0){
finished[i] = array[i];
}
}


I'm really sorry, but I can't even explain it right.
Think of it as PiD process, the first has 2 requests to execute(array[0] = 2) and the second has(array[1] = 1) and the program must run it until all requests are equal 0, but the first process must run one time and then let the second process run one time before running his last time.

Sorry if I wrote like a animal and hope someone can help me.
>>
>>51558643
Hurdur didn't see that coming,
fuck yourself
>>
>>51558619
>MVC

wackity schmackity don't.
>>
>>51558011
Now with nicer output!
:~$ ./lolisp date-format.lisp

((((()((((((((((((((((((()(()(((()((()(((((()((()((((()((()((()((()((())((())))
((((()))((())(())())(((((((()((()((())((()(((((())((((((()(((()))((())))))((()(
))))))(((()))((((((((())))(()((((())((())((()))((()))(((((())))(()((((())()))((
())()))(())())()))(())())()))(())()))((())()))((())()))(((((())))))(((((())((()
)))))((((())())))((()))))())))((((())))(((()))))(((()))))))))))))(((())))))))))
)))(((()))))))))))))(((()))))))))))))((()))))))))))))((()))))))))))))((()))))))
))))))((((())))))))))))))(()))(()))((((((()))))))(((()))))))((((()))))))(()))))
))(()))))))(()))))))(()))))))(()))))))(()))))))(()))))))(()))))))(())))))))))((
))))))))))((((()))))(((()((())))))))))(((()((())))))))))(((())))))))))))((((()(
))))))((((()())))))((((()())))))(((()())))))((()(()())))))((((()())))))))(((()(
))))))))((()(()())))))))((((()())))))))(((()())))))))(((())))))))))((((()()))))
))((((()()))))))((((()()))))))(((()()))))))(((()))))))))(((()(()()))(((()(()())
)(((()(()()))(((()(()()))((()(()()))((())(()()))((((()())))))(((()())))))((()()
())))))((((()())))))(((()())))))((())())))))((((()())))))(((()())))))((())())))
))((((()())))))(((()())))))(((()))))))(((()))))))))(((()))))))))(((()))))))))((
())))))))))))((
>>
>>51558714
>ends with open braces
Dear god.
>>
>>51558714
>nicer
and wrong
>>
>>51558738
:~$ ./lolisp tbqhfam.lisp
()()()()()()(()((())()()()(((())))))(((())(())(())(())(())()()(())(())(()())(())
(())(())()(())(())(())(())(())(())(())(())()()))(()(()()))((())((((()))(())(())
)(()(()())())))(()((()())(()())()))(()(())(())()(()))()(()((((())))(()())(((())
(((()))(())(()())))(()()()(())))))(()((((())((()()))(()))())))(())(()(((()))(((
))(()))()(())))(()(((()))(()(()(()(())()()))(((()))(()()(())(())(()()))((()((()
)())))((((()())))(()))()(()())(()(()()))(())(()())(()())((((()())(()(())())))()
)()((((())(()))(()(())()(((()(()()()()))))(((((()()())))((((()))(()))(())((())(
()()))(())))(()()())(()(())())))))()))))(()()(((()))(()())))(()(((())((()()))((
(())))(()))()()(((()()(())(()))(()))(()()())(()()))(()(()()()()()()()))))(()(()
()())(()()()((((()))(()))(()()()((((()))((((()))(()((()(())((()))))))))(()((())
(((())((())))()()()())))(()))(()((())((((()()(()()())))((()()))(()))()()(()(()(
)())(()()())))))))))((()(())(())(())(()))(()(((((())((()))(((()())()))(((()())(
()()()))))))(()))))(()(())((()(()))))(((())(())())(()())((()(())())())((()(()))
())((()(()))())(()((((()())))())()((()(((()))(())(())(())(())(())(())(()))))))
>>
>>51558534
post sample output ie; port, ip etc.
>>
>>51558800
>c᠎uck
>>
>>51558906
At least my paren keys aren't worn down to the nub. Gimme your finest lisp work and I'll lolispify it for you free of charge friend!
>>
What's the best way of doing this in a general purpose programming language?

Table[x, {x, 2, 1000, 6}] * Table[x, {x, 1, 1000, 6}]


This multiplies every sixth even number from 2 to 1000 with every sixth odd number from 1 to 1000

>tfw mathematica is easy as shit for math stuff
>>
>>51558802
Hold on. Hoooold on. I think I've found what's causing it.
>>
>>51558939
>my paren keys aren't worn down to the nub
neither are my mouse buttons, webfag
>>
>>51558944
ArrayFire + C++
>>
>>51558980
webfag? lmao fuckin mad2thecore.
Have a pity ((((((((((you))))))))))
>>
me in the trash
>>
>>51558965
So as it turns out, HTML at the end of a line doesn't do \n but \r\n. So I still had a \r dangling off the end, that's why it didn't work.
Now off to solve the numerous other problems the code probably has.
>>
>>51558944
For loops
>>
>>51557887
>>51557892
if youre both on the left and right does that just make you still alone, anon?
>>
>>51559015
I presume you mean http? Because this has nothing to do with html.
>>
>Be me
>Lose coding job
>Try to fuck around with the django shop tutorial
>Fucking south cant go past 1.6
>Fucking around with installed apps section for hours
>Finally get it working
>Forgot to make templates
>Sigh

Is there a good way to do legitimate web programming or am I just going to want to shoot myself for the next 10 years?
>>
>>51559056
Yeah that. I guess in a way the anon who told me host was wrong was correct.
>>
>>51559058
>webdv
better jump off a cliff right away
or start learning PHP and SQL
>>
>>51558990
>memejs mad faggot confirmed
>>
File: bat.webm (2MB, 640x360px) Image search: [iqdb] [SauceNao] [Google]
bat.webm
2MB, 640x360px
Ask your beloved programming literate anything.
>>
>>51559086
but anon, lolisp® was made in C © Meme Enterprises, "Making lispfags asshurt since 27/11/15"™
>>
>>51559100
Do you realize that you're not beloved?
>>
>>51559058
learn Go

>>51559100
why do you keep calling yourself "programming literate" if, IIRC, you once said that you have been programming for only 4 months?
>>
>>51559100
How do I prevent cheating in a client/server model for a rhythm game?
The problem is validating the keystrokes of the client. I have to make sure the client does not spam the server with keystrokes or create a bot that automatically presses the right keys.
>>
A calculator with GUI using Tkinter
t. Babbys first CS course
>>
>>51559209
You don't. (Not that guy.)
>>
>>51557857
if i learn C++ will i learn C in the process?
>>
>>51558678
http://pastie.org/private/onfnr0fmd64rwidlyqjsna
>>
>>51559235
Should I send over a hitsquad if I detect a cheating client?
>>
>>51559236
If you learn C++ correctly, no. And you shouldn't want to.
>>
File: umaruwp.jpg (112KB, 1920x1080px) Image search: [iqdb] [SauceNao] [Google]
umaruwp.jpg
112KB, 1920x1080px
>>51559186
>>51559194
please, don't bully.

>>51559209
you can't.
>>
>>51559244
Yes.
You may accidentally kill a few legitimate people though.
>>
>>51559209
Short of monitoring the player's keyboard by webcam, you can't
>>
Gather round folks, we've extended our product line! Introducing... Hahaskel.
->::<><-><><><><><-----><><----->::<-><><><><><-----><><----->::<-><><><><><-----><
><----->::<-><><><><><-----><><----->::<-><><><><><-----><><----->::<-><><><><><----
-><><-----><><><><-----><><-----><><><><-----><><-----><-><><->::<><-><><-><><><><><
-----><><-----><-><><><><><-----><><----->$<-><-><><-><><><-><-><><-><><><><><><----
-><><-----><><><><-----><><-----><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><->
<><-><><><-><><><><><-----><><-----><-><-><><-><><><-><-><><-><><><-><-><>-<-><><><-
><-><><-><><><><><><-----><><-----><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><
-><><-><><><-><-><><-><><><><><><-----><><----->$<><><><-----><><-----><-><-><>-<-><
><><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><-><><-><><><><><><-----><><-----
><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><><><><><-----><><--
---><><><><-----><><-----><-><><->::<><-><><><><><-----><><-----><-><><-><><><><><--
---><><-----><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><-><><-><><><-><-><><->
<><><-><-><><-><><><-><><><><><-----><><-----><-><>$<-><><-><><-><><-><><-><><-><><>
<><><-----><><-----><><><><-----><><-----><->--<><><><><-----><><-----><-><><->::<><
-><><->-<><-><><-><><><><><-----><><-----><-><><-><><-><-><><-><><><-><><><><><-----
><><-----><-><>-<-><><><><><-----><><-----><-><><-><><><><><


Unfortunately it was too memey to fit in this tiny box.

:~$ ./hahaskel Config.hs | wc -c
6830
>>
>>51559307
I could do the same thing for C using braces and semicolons

>Config.hs
Fuck off
>>
>>51559330
Hey, I didn't write that hahaskel file.
I pulled that gem right off of github, as I did my lolisp files.
>>
>>51559347
>tfw no loli/sp/
>>
>>51559380
kek
>>
>>51558271
>why should I switch to iPhone or Android when my blackberry works fine?

Nice b8 m8
>>
>>51557857

I'm programming an Atmega328p in C with the avr-gcc compiler, I can understand all of the logic of all the example code I have read, but the bitwise shit confuses me

First of all: why do programmers do bitwise ORs to individual bits and bitshifts like this:

     ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // Set ADC prescaler to 128 - 125KHz sample rate @ 16MHz


is their a reason they don't just set the registers like "ADCSRA = 0bxxxxxxxx;"?

also, say I want to invert the last bit in a register. How could I do this with the _BV macro?
>>
>>51559243
I got it! Thanks alot!
>>
This one's a real beaut'
:~$ ./hahaskel meingott.hs
-----_-----::-<><><><>->::->->->->->--::->->->->->->->_______--$::->->->->_-><$
>___-><$><$><><><><>$<>::->->_->::->->-><$>---><$>-><$>-><$>:_->--____::_____::
<><>::->->$<><><><><>:<>::>--><--<<>-->><<::->$::<><>$-_-_-::::-><><><>::->->__
______----<><>::->->_:<>_____<><><><><><><><>_::__<><><>--<><><>_:<>_____<><><>
<><><><><>------____$<$><><><><><>__::<><>->-><><>$<><><><><>-><><><>::_::->$$$
--::<><>_<><>__::<><>__<><><><><>_::::-::_____::::--___::::::_<><>::_::::-><>__
<><><>___<>___<>_<><><>::-><><>::->->->-><$>::->->->->::->->::-><>::-><>$<><><>
<><>::-><>::$::-><>::$::->-><><><>::->-><>::->->_<>_<><><><><>::->-><><><><><><
>:_-><>_->->_->->_->_->::->->->$->$-><>$<>-><>$<>->_<><>_-><>::::->$::->->><>:-
><><>_::-><>::->::-><><><><>::->-><><><><>::-><><><>$$<$>$$<$>::<>::->->->-><><
><><>
>>
>>51559560
no one cares
>>
>>51559460
>is their a reason they don't just set the registers like "ADCSRA = 0bxxxxxxxx;"?
The reason is that when written like this, you can't see what the individual bits mean. Using bit shifting, when choosing appropriate names for the constants, it is obvious what your bit manipulation is accomplishing.

Compare:
REGISTER_MAGIC |= (1 << ENABLE_FROBNICATE_MODE);

Versus:
REGISTER_MAGIC |= 0b00000100;


Admittedly, the constant names used by the AVR library are really really terrible for that.

>also, say I want to invert the last bit in a register. How could I do this with the _BV macro?
You would write:
MYREGISTER ^= _BV(0);

But personally I wouldn't bother, and just write:
MYREGISTER ^= (1 << 0);
>>
>>51559654
About FP? I know right.
^5
>>
>>51559036
>feelsbadman.jpg
>>
>I judge the worth of programming languages by how many punctuation characters they use
>>
why is type erasure bad
>>
Now with more meme!
:~$ ./lolisp ast.lisp
:(<>)<>(<>)()(:)(:(:::)(::<>:<>::::<>:<>:<>:<>:<>:<>:<>::<>::::<>:::))(:)(<>()(
))(<>(<>)((::::)(::::)(::::)))(((<>))(()))(<>(<>)())(<>(<>)())(<>(<>)())(<>(<>)
())(<>(<>)())(<>(<>)())(<>(<>)((::::(<>))))(<>(<>)((::::<>)(::::<>)(::::<>)))()
(<>()(<>))(()(()(((())(()))(((()())(((()))((())(((>())(((<>:))))))))(((())(()))
)))))(()(()(((())(()))((()(((())(()))((>())((())(())(((())(()())())))(()()(()))
)))(((())(())))))))(():**(()))(()((()()((())(())))))(()((<>)(())))(()(((*())(*(
)))(**)))


Don't forget to like and subscribe.
>>
>>51559806
Less safety yet often also less efficient
>>
File: Selection_031.png (14KB, 316x209px) Image search: [iqdb] [SauceNao] [Google]
Selection_031.png
14KB, 316x209px
What's the best format style and why is it pic related?
>>
>>51559826
Now create a triangle with the characters.
>>
is scheme a meme today?

what are you using it for?
>>
File: C unites workers.jpg (2MB, 2000x2610px) Image search: [iqdb] [SauceNao] [Google]
C unites workers.jpg
2MB, 2000x2610px
>>51559933
>CPeePee
>not C
l m a o
>>
>>51559412
try typing quickly and accurately on a touchscreen. its like pulling teeth
>>
>>51559974
Scheme is a great language for learning, among other things. It's definitely not a meme.
>>
>>51559826
your shit program could be done with sed in a bash script

>>51559974
scheme sounds like a meme
>>
File: 14082176934965.jpg (282KB, 1000x1000px) Image search: [iqdb] [SauceNao] [Google]
14082176934965.jpg
282KB, 1000x1000px
>>51559933
>semicolons before end of line
>>
How come GCC adds so much garbage data to the executable?

I compiled a super simple C hello world program and opened it up in a text editor. Deleting null characters left and right is really cutting down the binary size but it doesn't have any effect on the program. What gives? I've always been told that compilers are better at producing machine code than humans, but...was that just a lie?
>>
>>51559933
>std::cout
disgusting
>>
File: 6.png (20KB, 300x300px) Image search: [iqdb] [SauceNao] [Google]
6.png
20KB, 300x300px
>>51560102
>and opened it up in a text editor
>>
>>51560102
GCC doesn't optimize for size by default
>>
>>51560102
debug data?
>>
>>51560122
Well, a hex editor (okteta), but the point still stands.
>>
>>51559974
schmeme you say?
:~$ ./schmeme 10-value-of-all-of-this.ss
:():::((()((())(()))))(()())(()())(()(()()))()((()((()))))()(()())(()())(()(()(
)))((()()))((()(())))((()((()))))((()(()())))((()((()())((())())((()())))))((()
())(()()))>((()())(()()))>()()()((()())(()(()())))()((()((()())((()(()(()))))))
)(((()())(()()))(()()))>((()((()())(()))))((()((()*)(()*)(()*)(()*)(()*)(()*)((
)*)(()*)(()*)(()*)(()*)(()*)(()*)(*))))((()(((())(((())*)((())*)((())*)(*)))(*)
)))((()(())))((()(())))*(*(()((())(())(())(()))))*:()(*(()()))()*(*(()()))((()(
())))*(*(()((()))))()()()((()((((()))((())))(((()))((())))((())))))((()((()())(
))))()()*(*(()(())))()((()((()())(((())(()))))))*(*(()((())(()))))()()((()(()))
)((()(())))((()((()(()))(()(())))))((()((()(()()))(()(()))(()(()))(()(()))(()((
)()))(()(:()))(()(()))(()(()))(()(()))(()(()))))):(:(()((())(())((()))((()))())
))((()(()((())()))))(())((()))()(((())))(((())))()(((()((())))(())))(())(((()((
())(()))))):::
>>
>>51560102
>GCC
>not MSVC
why live?
>>
>>51560158
>MSVC
>not MinGW
burn your computer
>>
>>51560102
The error messages I get when I delete "relevant" parts of the file is interesting.
>>
>>51560179
>MinGW
>Not even worth killing yourself
>>
File: cat.jpg (14KB, 480x360px) Image search: [iqdb] [SauceNao] [Google]
cat.jpg
14KB, 480x360px
>>51560150
cat

universal meme detector

super sensitive

and cute!
>>
>>51560219
>cat
>not dog

Diesel is rolling over in his grave
>>
>>51560219
I am on board with this.
>>
>>51560158
>C89
>>
>>51558944
[even*odd for (even, odd) in zip([even for even in range(2, 1001, 12)], [odd for odd in range(1, 1001, 12])]

This does an element-wise multiply of even sixth even with every sixth odd. Unless you meant all permutations of like [1, 2, 3] * [1, 2, 3] = [1, 2, 3, 2, 4, 6, 3, 6 9].
>>
>>51560270
>C
>>
>>51560194
>>51560102

Well I managed to get a 6.6KB executable down to 2.1KB.

That means that roughly 66% of the file was useless bloat.
Is this normal? If so, why? Are programming languages just a meme, trying to stop us from using hyperefficient assembly?
>>
>>51560040
>old language
>not older language
>>
 double scale = (temp - cold) / range; //temp: 14 range: 40 cold: -10 scale: 0.0 


why is scale 0.0? 24/40 = 0 ?
>>
>>51560150
Do a standard test or something like fizzbuzz and compare languages.
>>
>>51560451
I was just grabbing stuff I found on various githubs, I don't know how to functional program nor do I want to, but if you'd like to write up some, I would be glad to memify them for you post-haste.
>>
>>51560448
What lang?

24/40 will equal 0 if 24 or 40 is being interpreted as an int.

If this is C++ or something, try this and see what happened:

double scale = (double)((double)temp - (double)cold) / (double)range;
>>
>>51560289
now try with -O2
>>
>>51560530
oh god I'm so fucking stupid
thank you, yes it was because of integer division
>>
File: scratch.jpg (67KB, 480x270px) Image search: [iqdb] [SauceNao] [Google]
scratch.jpg
67KB, 480x270px
I'm having trouble understanding why Scratch exists and if it's good for children.

Because from my perspective Scratch is just another way to write code which is often coupled with a couple libraries that allow you to do basic things like opening windows, displaying images and playing sounds.

But you're never going to ship anything made in Scratch right? If text-code scares these people then why would you ever bother to help them? If it's other things that scratch does to get rid of what scares people about programming then what could that possibly be and how could you construct something which is actually helpful to their learning?

If you have a fresh Scratch baby and you want to toss it into C, Java or whatever it's very unlikely to float better just because you taught it to drag blocks and understand what a library is (loosely).

And I can't really assume the Scratch devs didn't think of this. There must be something I'm missing. Because who would write an entire language with its cool UI and stuff without having through about these things?

Personally my issues with programming was the level of abstraction I was thrown into. If I could write something similar to C code on a computer which just had buffers for character, video and audio output (and input). I have no doubt I'd have an easier time than the problems you're faced with early on in object oriented programming for instance. So why would you take away one of the few things that were solid, the code you input to the machine? Making it an almost entirely black box.

And I'm told Scratch works, there's tons of communities who try and teach kids scratch. But I don't see how at all. And what is their measure of success?
>>
>>51560648
Scratch was, to my knowledge, designed to be a not shitastic version of Alice.

Friendly reminder that there's actually a large number of high schools who teach Alice in their intro to programming classes.
>>
>>51560648
scratch is good for kids cause it is literally impossible to write programs in it that:

- have syntax errors
- crash or lock up
- run out of memory
- don't have some kind of simple visual feedback

you would be surprised how far that gets in teaching small impatient children
>>
>>51560648
>>51560672
Apparently a course I'm taking next year called "animated computing" is done in Scratch

In a university CS program
>>
>>51560451
Hello world:
:~$ ./hahaskell helloworld.hs

:~$ ./schmeme helloworld.ss
((()(()()())))

Result: schmeme is memier.

Fizzbuzz:
:~$ ./hahaskell fb.hs
_||||
:~$ ./schmeme fbrecur.ss
(()((((()))((()))((()))()))((<)(())))()
:~$ ./schmeme fb.ss
(((()))((>))((((()))((()))((()))()))())

Result: Schmeme memier.
>>
>>51560289
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html

>>51560689
>In a university CS program
what uni?
>>
>>51560689
What shitty uni is this?
>>
>>51560648
Honestly I don't know why it exists either. There is no use in teaching kids to program, it's too abstract for them. It's something that should be introduced after kids learn algebra and their first algorithms.

Captcha was Euler Ave., lel.
>>
>>51560289
did you try using the -s flag? there are some other flags for linker to reduce size IIRC
>>
>>51560699
$ ./chit < chit.c
(){;((())!)(){';':'{':'(':')':'}':'|':'\\':'&':'\'':'\"':':':'!':();}('\');;}

oh my :^)
>>
>>51560720
>>51560725
Dalhousie in Canada

And I just looked up last year's syllabus and there's no mention of Scratch, so I guess somebody just had no idea what they were talking about when they brought it up
>>
>>51560797
That's beautiful though. Plus bracketed languages make sense!
How is bitwise operators a meme?!
Confirmed speech impediment.
>>
>>51560648
my university had the entry course for programming held in scratch. I still not understand why they did it.
>>
>>51560689
That's pretty heretical.
Though there may be reasons for it.
>>51560672
Yeah but my problem is with having an environment like that. Unless Alice was straight up harmful compared to scratch they're the same to me
>>51560685
>- crash or lock up
I'm fairly certain you can do this..
>- have syntax errors
I don't find it helpful to make logic errors out of syntax errors. And I'm having trouble picturing a kid who would have problems with a syntax error more than a logic error. Logic errors are invisible. The machine "just don't work" as I picture the child would think. While a syntax error would tell him what he did wrong and he'd go like "yeah that's not what I wanted".
>- don't have some kind of simple visual feedback
How can this not be true? If you make an intermediate calculation in scratch it's just plain visible somehow?
>- run out of memory
I guess. But really at the stage these programmers are at it'd be hard to run out of memory.

>you would be surprised how far that gets in teaching small impatient children
Yes very surprised. Especially about the syntax vs logic errors.
>>
>>51560797
but let's be real
:~$ ./lolisp tbqhfam.lisp
(:)()()()()()(()((():)(:)(:)(:)(((()):))))(**((()::)(()::)(()::)(()::)(()::)(::
:)(:::)(()::)(()::**:)(()::())(()::)(()::)(()::::)(::)(()::::)(()::::)(()::::)(
()::::)(():::)(():::)(():::)(():::)(:::)(:::)))(()((:::)(:)))(((**))(((((:)))((
))(:()))(()(()(:))(:))))(()**((()(:**::))((:)(**))()))(()(())(())(:**)((:)))(**
)(()((((:(:))))((:)(:))(((())(((:**(*:**)))((:))((**)(::::**))))(()(:)(**)(()))
)))(()((*(((:))(((:)(:***)))(()))())))(**())(()((((:)))((()**:)(:()))(:)((::)))
)(()(((()))(()((:**)(()(())()(:)))((((:)))(**(:::)**(:::)(**(:::))(**(::))(()()
)):((**()(((**))())))((((()())))(**(:)))()((::**::**)(:**))((**)(()()))(())(()(
:))(()(:))((((()(:))(()(())(:))))(:))(**)((*((**())(**()))(()(:(:**))(:**)(((()
(()(:)(:)(:)))))(((((()(:)(**))))((((()))(()))((:))((())(()()))(())))(()(:)(:))
(()(())(:))))))(:)))))(()()(((()))((:)(::))))(()(*((())((()()))(((())))(()))(::
)(::)(((()()((:))((:)))(()))(()(:)(:))(()(:)))(()(:::():():():():():():():))))(
()(()(:)(:))((:)(::)()(*((((::)))((:::)))((**)()(:)((((:(:)))((((()))(()((()(()
)((()))))))))(()((())(((())((())))(:)(:)(:)(:))))(:::(:):))(()((())(*(((:():():
:(()(::)())))(((*)()))((::)))(:)(:)(()((:)()(:))((:)()(:))))))))))((()((:**)**)
((:**)**)((:**)**)((:**)**))((:)(*((((())((()))(((()())()))(((()())(()()())))))
)(()))))(()((:::))(:(()(()))))((((:))((:))())(()())((()(())())(:))((()(()))(:))
((()(()))(:))((:)((((()())))(:))(:)(((:)(((:(:)::::))((:::::))((:::::))((::::))
((::::))((:::))((:::::))((:::::)))):)))
>>
Guys, how to "rethink" logic ?

I have a piece of logic written down that doesn't seem pretty, but there's nothing that else comes up in my mind.

How do you get into rethinking logic?
>>
>>51560825
To get women interested in programming.
>>
>Program hangs when window is moved/resized
So, I guess the correct way to fix this is to run my window/event loop on a separate thread to rendering, right?
>>
File: scratch.png (55KB, 576x622px) Image search: [iqdb] [SauceNao] [Google]
scratch.png
55KB, 576x622px
>>51560648
>>
>>51560872
lol turd
$ ./chit < gnuecho.c
():();:""('')""\("")\(""){};(){(!)();{(("\:\\:\\"));(("\()\\\\\\"));((("\()\\\"):("\\\()\")));();();(("\\\:\\\\"));(("\\\\\\\\\()\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"));(("\\\()\\\\()\\"));();();}();}(){(){:'';'':'':;'':'':;'':'':;'':'':;'':'':;'':'':;}}'''(){;(!("")||(!&&&&("")));';(&&);();("");();();();(&&){((""))();(("")){(());;}};;()(&&''){;;(;;)(){'':'':'':;:;}();()(){'':;;'':;;'':;;};;}:(){(){;;(()){('\\'&&){(){'':'\';;'':'\';;'':;'':'\';;'':'\';;'':'\';;'':'\';;'':'\';;'':'\';;'':{;(!());;();;(()){;();}};'':;(!(''&&''));;'':'':'':'':'':'':'':'';(''&&'')('');(''&&'')('');;'\\':;::('\\');;}}();};;()('');}}{(){();;;()('');}}()('\');;}
>>
>>51560734
>There is no use in teaching kids to program, it's too abstract for them.
I disagree. What kids would need is advanced visualization tools. As I suggested just a couple of buffers and an easy interface into them would be fine. Perhaps an abstraction layer on file encoding and stuff (Basically convert every jpg/bmp/png into a plain obvious bitmap format). Then if you have an UI which shows what happens in every stage of the program the kid can easily figure it out. Presuming they're not writing things that are too complicated.

I don't think my problems were the complexity of the programs really. It was just how I had to interface with things.

And if they're actually writing something that's out of their reach then have a step by step process where they can receive live-adult intervention or something (the steps would be asking the child to check things, or have the program do it for them).
>>
>>51560881
There is no 'howto' on logic. Just keep at it.
>>
Is there a way to make exe/command line applications with python natively. So that someone else doesnt need to have python installed to use it. Theres some really old programs I made that I dont want to convert and it could be of use still. I know there are programs like pyexe but Im interested in whether theres already a way to run a python script without having python installed that python supports.
>>
>>51560844
no you don't understand, it is impossible to have a syntax error in scratch because all the coding is done with blocks that snap together, if you can't do something in the syntax of the language than the program will literally not let you snap the blocks together. that constraint is really helpful because it visually teaches about programming syntax without needing much explanation
>>
>>51560918
It's not programming. Programming is logic and math. That shit is just legos. Legos don't teach you physics.
>>
>>51560917
what'd you write it in?
and cmon man,
if (count % 80 == 0) {
putchar(10);
count = 1;
}
>>
File: 1369446960901.png (20KB, 256x310px) Image search: [iqdb] [SauceNao] [Google]
1369446960901.png
20KB, 256x310px
>>51560942
>Windows doesn't even have interpreters for the most popular scripting languages
>Ever developer has to ship their own interpreter
>200 versions of python on your computer
When will the meme known as 'Windows' end?
>>
>>51560961
And how does that help with kids? That's a syntax error if I ever saw one. Hopefully there's a popup which tells you what the problem is and suggests a str() or something.

I do see how it would be incredibly hard to implement that in text-code languages though. Since the set of character inputs is much larger and interpreting intent would be a harder problem.

>>51560971
So you really think that having them explore programming isn't helpful? What I described isn't necessarily legos. It can be anything. What i was explaining was that I don't think it's the logic and math (to some extent) that trips people up. Sure, you can't expect a kid to get as far as your 40 year old software engineer but further than nothing is a good head start.
>>
>>51561010
I guess not. Ill just tell them to suck it up and install python until I convert it then.
>>
>>51560942
py2exe is something I've heard of I think. Dunno how it works or if it works well. Supposedly constructs executable files though.
>>
>>51561010
>Windows doesn't even have interpreters for the most popular scripting languages
So? Neither do Arch or Gentoo*. There's literally nothing wrong with that. Including those interpreters because a program /might/ use them is retarded and creates stupid bloat in the OS.
Anyways, they are "scripting languages" for a reason. You shouldn't be using them to write a desktop program, you should be using them to make (and possibly distribute) scripts for people with technical knowledge (in which case they would either already have the interpreter on their computer or would know how to install it).
*(unless required for compiling some program, in which case it will be installed. for example, since portage is written in python that's included)
>>
Hey /dpt/.

I've made a rudimentary gamepad to control flash games, NES emulators, etc. using an arduino uno. I couldn't initially get HID to work so I'm using my arduino sketch to output strings to the serial on event triggers, and have a Java program to monitor the serial to then make keypresses with Robot.

It lags. Slightly, but noticeably. If you're playing a game with a lot of precise button mashing, you'll see commands being executed after you press them.

Is this an issue with my method? My code? Would HID fix this?
>>
>>51561095
>Neither do Arch or Gentoo*.
Distributions especially made to be small and "unbloated"/customizable.

Windows has clearly abandoned that goal if it ever was a goal.

The solution in true windows fashion would be to recommend the user to install MS Python Interpreter for 29.99$ through the windows store (whatever it's called).
>>
>>51561095
>Neither do Arch or Gentoo
You can trivially obtain them with your package manager. Even if they're not installed by default, the distro still 'ships' them.
>You shouldn't be using them to write a desktop program
While I agree for the most part, not everyone thinks the same as you.
>>
I need some ideas for a project.
It needs to use file input / output, and hashmap / hashset.
I could do an inventory thing, but I want something that's more fun to watch.
I was thinking of making a simple path finding visualizer, or algorithm / math visualizer (showing where the derivative and integral come from and what they represent, power series, etc).
The project is meant to be a final review of java and object orientation basics.
>>
>>51561040
there is no popup, visually they don't connect and you just can't snap the blocks together. scratch has actually taught me that popups and error messages are HORRIBLE ui

also
>If you make an intermediate calculation in scratch it's just plain visible somehow?
yes, if you disconnect any block and click on it it shows you the result of the computation
>>
>>51561129

Update: It's less about the lag and more that if you make a lot of inputs in a short amount of time, it gets backed up and executes them in order after they've been triggered.

I can't tell if this is an issue that could be fixed in my code or if I need to ditch serial and move to HID entirely. HID would probably fix it but I want to make serial work!
>>
>>51561205
>scratch has actually taught me that popups and error messages are HORRIBLE ui
Yes. But what i mean with popup isn't the kind that interrupts flow. I mean the more general sense of alerting the user. What you could do is have a small "hoverbox". Like the kind you get when you hover over something in many UI systems (see pic). It wouldn't interrupt flow but it'd be immensely helpful for every kind of user, veteran user who aren't entirely sure on what kind of block they're holding and new users who don't know what's supposed to go in the slot.

>yes, if you disconnect any block and click on it it shows you the result of the computation
So variable inspection? Perhaps I'm misunderstanding the way Scratch is run.
>>
>>51561183
romanji to katakana converter
>>
Fleshing out a simple linked list in C.

LISTS ARE POWERFUL

http://pastie.org/private/k2m2iy98rq5qyynvhnabqg
>>
>>51561363
>[Update] [Auto] 10
Can you implement this in schmeme so I can memify it?
>>
>>51561370
lol why the fuck was that highlighted
>>
>>51561129
>Is this an issue with my method? My code? Would HID fix this?
It's incredibly hard to tell what the problem can be without knowing what you've done. It could be a polling issue, it could be input lag in the application you're driving (maybe the game isn't responsive to gamepads or whatever).

If you're really stuck I'd find a way to profile the code. Aka figure out the first instance where you can make a timestamp for when you've pressed a button. Then time at different places so see where the biggest time difference is. Likely your problem is there.
>>51561224
>It gets backed up and executes them in order after they've been triggered.
Well the inputs should never be "backed up". Unless that's intentional design of course.
You can try and time if your OS is too slow on the serial port but it seems unlikely that that'd be the problem. Again, hard to tell without more information.

Profile it.
>>
File: image.jpg (97KB, 476x400px) Image search: [iqdb] [SauceNao] [Google]
image.jpg
97KB, 476x400px
>>51557857
Trying to make an ICBM guidance system with python
>>
>>51561493
reported
>>
>>51561493
based korea is best korea
>>
>>51560971
>it's just legos

if it's not assembly, it's lego
>>
>>51558221
A Y Y
Y Y A
Y A Y
>>
File: 1446407357663.jpg (194KB, 1280x720px) Image search: [iqdb] [SauceNao] [Google]
1446407357663.jpg
194KB, 1280x720px
>>51561636
What do you want
>>
>>51558116
anyone worth their salt doesn't use python at all
>>
>>51561647
Fuck, I was about to make the same joke.
>>
>>51561651
anyone worth their vinegar only uses python
>>
>>51560689
>>51560808
>(north) murrica
>>
>>51561669
given that vinegar never had any particularly high value as a commodity, this is true.
>>
>>51561730
K E K
E K E
K E K
>>
>>
>>51561751
They must sell clothing for 'bloated' people.
>>
anyone worth their spice uses C++/D
>>
>>51561751
the hell kind of business idea is that
>Glib Man™ Quality Menswear & Accesories | Lifestyle Be glib. Be you.™ #glibmanmenswear
they actually paid for those trademarks?

maybe it's like the xbox one, the name is so retarded that people will talk about it and indirectly shill for the company
>>
>>51561834
>indirectly shilling [redacted]
>>
File: 1434229519851.png (210KB, 871x900px) Image search: [iqdb] [SauceNao] [Google]
1434229519851.png
210KB, 871x900px
I'm using argp:

#include <stdio.h>
#include <argp.h>

static int parse_opt(int key, char *arg, struct argp_state *state)
{
int *arg_count = state->input;

switch (key)
{
case 'd':
printf("HurrDurr\n");
break;

case ARGP_KEY_ARG:
(*arg_count)--;
if (*arg_count >= 0)
printf(" %s", arg);
break;

case ARGP_KEY_END:
printf("\n");
if (*arg_count > 0)
argp_failure(state, 1, 0, "too few arguments");
else if (*arg_count < 0)
argp_failure(state, 1, 0, "too many arguments");
break;
}
return 0;
}

int main(int argc, char *argv[])
{
struct argp_option options[] =
{
{0, 'd', 0, 0, "Hurr"},
{0}
};
struct argp argp = {options, parse_opt, "WORD [WORD [WORD [WORD]]]"};
int arg_count = 1;
int rv = argp_parse(&argp, argc, argv, 0, 0, &arg_count);
return 0;
}


How can I set flags for the arguments?
For instance instead of
case 'd': //branch off into fucking eternity
I would rather
case 'd': flag_d = 1; break;
and then just check the flag when I need to decide what options were set.
The problem is that argp has that callback
parse_opt
with a specific set of formal parameters, so I can't pass in a struct of my own containing flags, and I can't return one because
argp_parse
expects the callback to be of type int and also return 0, otherwise error.
The only thing I can think to do is make a global struct or a set of global static variables to act as flags, but I feel like that would be stupid since the argument parsing phase of my program is by far the least significant part so it would be overkill and bad practice to make things indiscriminately visible to the entire file just because I need to access it from one specific tiny function.
What do?
>>
>>51558211
>he is literally named guido
kek, what a meme language for cs memesters
>>
>>51561893
C stands for Christian language
this is now a Christian thread

if your language doesn't have static typing, it's shit
if your language can't be compiled, it's shit

crusades when
>>
File: fixed_1.png (43KB, 1203x640px) Image search: [iqdb] [SauceNao] [Google]
fixed_1.png
43KB, 1203x640px
>>51558402
Yes, yes I do. Prepare to be in psychical agony looking at my code.

https://github.com/Partinarel/map-make/tree/master
>>
What's the best C++ book for somebody who's already taken a shitty college course and wants to actually learn the language? How's Stroustrup?
>>
>>51561949
Remember the 4th crusade.
>>
>>51560419
>old language = bad language
>>
>>51561974
>book
You're doing it wrong

>online tutorials
>online videos
>cppcon / other C++ (and C++ style languages) conventions

then learn D because it's better
>>
>>51560648
>needs flash
why? why don't they rewrite it in HaXe and port it to html5 directly?
>>
>>51561974
If you took a course you probably know everything you NEED to know.

Start programming and ignore all the C++ features (except function overloading and stuff because that's convenient).
>>
File: Untitled.png (3KB, 399x211px) Image search: [iqdb] [SauceNao] [Google]
Untitled.png
3KB, 399x211px
In Java Swing, what's the best way to lay out a GUI like this?
Like I want some components on one side, and another on the other side.

I had originally done a GridLayout to split the panel then a LEFT FlowLayout and a RIGHT FlowLayout, but if one side has more components then the other it starts to look weird really fast.
>>
>>51558219
literally worse than hitler
>>
So I'm now really pissed off at GCC.

With the -s flag a hello world program compiles down to an executable that's 4384 bytes. Any other optimization flag setup (-Ox or no flag at all) produces an executable that's either 6680 or 6688 bytes.

Manually writing and linking the assembly code that produces the same exact result when the program is run results in a binary that's 936 bytes.
NINE HUNDED THIRTY-SIX BYTES.

I now know that "GCC is better then you" really was just a meme because it produced code that was at BEST almost FIVE TIMES LARGER than my handwritten asm code.
>>
>>51562050
>the only metric of executable quality is its size
>>
>>51562068
It is when GCC's "optimized" flags produce grossly unoptimized code.
>>
trying to iterate over a perl script but i can't figure out how to do it.

for i in $(seq 0 10 500)
do
echo Trying $i byte offset
./a.out $(perl -e 'print "\xff\xff\xff\xff" x $i')
done


i imagine the $i in the the perl line doesn't get substituted because it's nested in another $() block, but i don't know how to get around that...
>>
>>51562068
space is more limited than time
>>
>>51562050
Use the -Os (optimize for space) flag you idiot
>>
>>51562050
>936 bytes
For Hello World? That better be a GUI program!
>>
What the fuck?
This is my code:
print n, 25
print n > 25

This is what Python tells me:
5 25
True

Are there ghosts in my code? Did mathematics get reinvented last night?
>>
>>51562050
Are you using the C standard library? I suggest not doing that if you care about executable size.
>>
>>51562017
Haxe is kinda cool but I can't help but see it as another C++ (or maybe closer to D?). It just looks like the developers found every cool language feature and then dumped them all into a single language without really considering how well the pieces will interact. The majority of the features go completely unused and then 90% of programmers can't read more than half the language. Then again, all the available backends gives it a point even if it isn't that great a language.
>>
>>51562100
If you'd read my post you'd realize that I did.
-Os resulted in a 6688 byte binary, as did -O1. -O2 and -O3 result in a 6680 byte binary.
>>
>>51562050
try writing a big program in asm. also, not all of that generated output is code...
>>
>>51562050
What are the execution times of the two programs?
>>
>>51559460
>invert last bit
>using a macro
Am I missing something here? Why not just XOR your register of 0x1?
>>
>>51562133
You said -s, not -Os
>>
>>51562050
Compile an actual application, not a hello world.
>>
>>51562127
>using the snake language
>>
>>51562127
Something is very wrong with your code. Why don't you post it in its entirety.
>>
File: dude amazon lmao.png (3KB, 534x85px) Image search: [iqdb] [SauceNao] [Google]
dude amazon lmao.png
3KB, 534x85px
I really wish I knew what the fuck was going on right now.
>>
>>51562127
What's the type of n?
>>
>>51562131
haxe uses the flash API and is similar to actionscript/javascript
I don't see how your post relates to scratch, though. haxe is the easy way to port flash code to HTML5+JS/Java/C++/...
>>
>>51562140
How would I test this?

>>51562130
Yeah, that might be it. Is there a way to access stdout in C without using the standard libraries?
>>
>>51562050
Did you
#include <stdio>
? If so, why did you expect your executable to be small?
>>
>>51562143
>>Any other optimization flag setup (-Ox or no flag at all)
Learn how to read, please.
>>
>>51562179
$ time ./hello_world
>>
>>51562043
It was a terrible course, and the "interactive ebook" that we used was such a bad textbook that I still don't know how to do half the stuff in C++ that I learned how to do in C from the first 100 pages of K&R.

>>51562007
The teaching style usually used by tutorials and videos is too pragmatic. I always learn things more easily from rigorous, comprehensive texts than from "intuitive" hands-on stuff.
>>
>>51562165
>xamarin
I bet you're even using MonoDevelop.
>>
>>51562050
you are a fucking retard. seriously, stop shitposting.

>>51562165
the govt of your beloved state union is messing with your packets, for being a dangerous anarcho-capitalist-libertarian
>>
>>51562169
kek, now I feel stupid. I used raw_input for n and forgot to cast it to an integer. Still a pretty cryptic result.
>>
>>51562215
Not really. If it's lexographical, then 5 is indeed bigger than 25.
>>
>>51562204

I'M TRYING TO FER FUCKS SAKE! I JUST WANT THE HUGE D IN MY MONODEVELOP BUT NO!

>>51562209
>the govt of your beloved state union is messing with your packets, for being a dangerous anarcho-capitalist-libertarian

I really wouldn't be surprised if they were. I have to imagine I'm on several lists for my positions.
>>
>>51562215
>Python in a nutshell
>>
>>51562215
That's why weak typing must die.
>>
>>51562179
>Is there a way to access stdout in C without using the standard libraries?
Naturally. You usually do it through platform specific system calls. Like "write" on linux.

Dunno about windows.
>>
>>51562174
>I don't see how your post relates to scratch, though
Oh i wasn't talking about it in the context of scratch.
I just decided to share my thoughts about Haxe in general
>>51562165
not down from here. try tracerouting it?
>>
>>51562082
Honest question: why did you chose to learn perl now?
>>
>>51560648
scratch is useful for teaching people structure and flow of programs. But that that point, you might as well just be teaching them to use Turing machines; they'll arguably be more useful to your learning of flow, structure and efficiency than anything in scratch ever will.
>>
>>51562251
>try tracerouting it?

Dead right out of the gate. I blame Verizon. Probably something going on between them and Amazon.

I just want my MonoDevelop and Rust nightly. :(
>>
>>51562251
>Oh i wasn't talking about it in the context of scratch.
>I just decided to share my thoughts about Haxe in general
oh, ok. well, that's the potential market for the haxe devs: port flash code, and/or make programs for a shitload of popular platforms.

>>51562237
or, perhaps, someone is using your wifi.
>>
>>51562291
Check your DNS? try 8.8.8.8.
>>
>>51562311

Already heard about the DNS issue, but I'm using Jewgle DNS already.
>>
>>51562291
You just gave yourself another reason to use Go. It even has a proper mascot.
>>
>>51562283
I strongly disagree with this. Turing machines are unnecessarily complex. The advantage of Scratch is the abstraction it provides, something Turing machines do not have. The difference between the two would be enormous for a beginner.
>>
Oh well, I'll wait a few days and see if this shit clears up.
>>
>>51562327

Go is on the list, along with a million other languages I want to learn.

Don't worry, I'm not neglecting it.
>>
>>51561129
use unojoy
trust me, just do it
you can even use your controller for a ps3
>>
>>51562320
Since you're a C# bro I'll help you out
>>
File: rob.pike.jpg (26KB, 500x335px) Image search: [iqdb] [SauceNao] [Google]
rob.pike.jpg
26KB, 500x335px
>>51562364
Better start learning Go now before its too late boy.
>>
>>51562291
Yeah AT&T fucking pulls this bullshit every so often and they decide to block certain web hosts. If you want you can probably call them up and ask what the fuck is going on, but they might just be assholes/retards about it. Last time I called AT&T about it they told me that "the IP range they're using is illegal and there are criminals operating on it" so I don't know how helpful it'll be~
>>
>>51562384
scan for viruses

not that it'll help
>tfw you download a compiler that injects viruses into programs you build
>tfw there are viruses that cause unknown errors, make you decompile the program to find the bug, but then are properly activated by recompilation
>>
>>51562409
>premature optimisations
>the language
>>
I'M SO FUCKING PISSED I'VE HAD TO CODE IN JAVA FOR TWO SEMESTERS AND NOW THAT MY CLASS IS ALMOST DONE I'M HAVING TROUBLE FINISHING MY SHIT. HOW THE FUCK DO I GET THIS METHOD CLASS TO WORK AND DON'T TELL ME NOT TO USE AN ARRAY BECAUSE THAT'S THE WHOLE FUCKING POINT OF THE ASSIGNMENT:

public class GenericStack<E> {
public static int size = 16;
@SuppressWarnings("unchecked")
private E[] list = (E[])new Object[size];

public void add(int index, E e) {
ensureCapacity();

for (int i = size - 1; i >= index; i--) {
list[i + 1] = list[i];

list[index] = e;

size++;
}
}
public int getLength() {
return list.length;
}

public E peek() {
E o = null;
for (int i = 0; i > list.length; i++) {
o = list[i - 1];
}
return o;
}
public E push(E o) {
ensureCapacity();
size++;
return o;
}
public E pop() {
E o = null;
for (int i = 0; i > list.length; i++) {
o = list[i - 1];
}
list[list.length - 1] = null;
size--;
return o;
}
private void ensureCapacity() {
if (size >= list.length) {
@SuppressWarnings("unchecked")
E[] newlist = (E[])(new Object[size * 2 + 1]);
System.arraycopy(list, 0, newlist, 0, size);
list = newlist;
}
}
public boolean isEmpty() {
if (list.length > 0) {
return false;
}
else {
return true;
}
}
}
>>
>>51562255
i didn't. i'm studying from a textbook that introduces perl as a way of generating arbitrary strings.

it's awesome, but that's about all i use it for right now.
>>
>>51562425
I literally just took two seconds to upload the installer.

In hindsight it would have been really funny to fill it with russian ransomware or some shit.
>>
>>51562436
>HOW THE FUCK DO I GET THIS METHOD CLASS TO WORK
I'm not gonna read through code to find a problem which you know about but I don't when I'm helping YOU.
>>
Anyone ever done a codility test?
>>
>>51562436
>fails at programming 101
>>
>>51562494
>peek always returns null
>push does nothing
>getlength returns 33 when i just added one thing to the array
>>
>>51562497

>2 hours long

I don't have that kind of time
>>
File: 1441417058260.jpg (401KB, 802x609px) Image search: [iqdb] [SauceNao] [Google]
1441417058260.jpg
401KB, 802x609px
>>51562409

N E V E R
T O O
L A T E
>>
>>51562130
>>51562184
will math.h add significant size if i only use sqrt?
>>
>>51562549
>>51562436
>public E peek() {
> for (int i = 0; i > list.length; i++) {

> public E pop() {
> for (int i = 0; i > list.length; i++) {

lel
>>
>>51562568
kek
>>
>>51562050
still better than msvc and clang
>>
>>51562436

Get better variable names.

PS: It's not Java's fault you can't code.
>>
sage animefags
trash
shitfagot
meme
>>
>>51562549
These are issues which should be very easy to solve if you step through the code.
>peek returns null
>i > list.length
Should be
i < list.length (i less than list.length) probably. Since you will never enter the for loop.

I don't see why the loop is there though. And your list peek should really just be accessing the first value right? It doesn't seem sane at all.

I don't know java and I despise OOP though.

Assuming you're not in a great hurry I recommend keeping your functions but deleting their contents entirely and just implement each one to your understanding of what a list is. Then see what problems you come up with.
>>
>>51562436
>two semesters
>can't use an array
>>
I get this exception when I get to the third question in the quiz:

Exception in thread "main" java.util.NoSuchElementException
at java.util.HashMap$HashIterator.nextNode(Unknown Source)
at java.util.HashMap$KeyIterator.next(Unknown Source)
at fenn21.PresidentQuiz.main(PresidentQuiz.java:51)


Line 51:

String name = president1.get(iterator2.next());


The class:

http://pastebin.com/0c3S0J8w
>>
>>51562598
>will math.h add significant size if i only use sqrt?
Read the code and see what it'd require.

If you really wanna be safe just copy out the function and pull in what bits of code you need manually. It would probably be the easiest way to go about these things.
>>
>>51562672
I don't understand how to make it generic. Seems like you guys are talking a lot of shit but not offering any solutions.
>>
>>51558011
Two can play that game. Here's what a program that reads C/C++/C#/J*va/etc. code and extracts the punctuation:
 ./lolc.out < qsort.c
#<.>#<.>(*,*,_){*=,*=,;(--){=*;*++=*;*++=;}}(*,_,(*)(*,*),,){(>){*=+;=+;=;(<){((+,)<=){+=;}((+,)>){-=;}(<){(+,+,);}}-=;(+,+,);(,,,,);(,,,,);}}(*,_,_,(*)(*,*)){(,,,,*);};_(*,*){(*(*))-(*(*));}(){/*=*/_[]={,,,,};=(_)/();*=;;(_,,(),_);(__={);(=;<;++){(%%,,_[]);=,;}(};\);;}


Before you say anything, it's written in C.
>>
>>51562480
funny for you and me
not funny for him
...but he is a tripcode...
>>
>>51562703
Unless it's formatted to 80 chars per line you can straight up go fuck yourself.
>>
>>51562695
Crybaby.
>>
>>51562748
I'm saying you don't actually know how to fix it. I'm calling you a hypocrite.
>>
>>51562695
I have anon.. >>51562670
The problem is not going to be us not helping ou in the future it's going to be that you're not laying any thought into the code.

Look at this:
 public E peek() {
E o = null;
for (int i = 0; i > list.length; i++) {
o = list[i - 1];
}
return o;
}

Ask yourself, what does a "peek" do. A peek looks at the first value you would want to access (first in the list apparently, I don't see why you'd want a 'peek' on a list honestly, but if that's the assignment then fine). So that's just
 public E peek() {
E o = null;
o = list[0];
return o; //if you want to write it this explicitly. You could write "return list[0];"
}
>>
programming is gay
>>
>>51562384

I appreciate it, but I'll bug Verizon to un-nig their shit and get it straight from the horse's mouth.

I'm probably not the only one affected, so I'll be doing some good.
>>
>>51562757
Do your own homework. You're not even trying.
>>
>>51562757
you're really good at asking people for help.
>>
>>51562733
>waah I can't scroll!
#<.>#<.>(*,*,_){*=,*=,;(--){=*;*++=*;*++=;}}(*,_,(*)(*,*),,){(>){*=+;=+;=;(<)
{((+,)<=){+=;}((+,)>){-=;}(<){(+,+,);}}-=;(+,+,);(,,,,);(,,,,);}}(*,_,_,(*)(*,
*)){(,,,,*);};_(*,*){(*(*))-(*(*));}(){/*=*/_[]={,,,,};=(_)/();*=;;(_,,(),_);(_
_={);(=;<;++){(%%,,_[]);=,;}(};\);;}+){(%%,,_[]);=,;}(};\);;}

enjoy your cancer
>>
>>51561051
>what is py2exe
>>
>>51562802
No way that's 80.
Also, is yours ansi compliant?
gcc schmeme.c -o schmeme -Wall -Werror -pedantic -ansi

feels good tbqh.
>>
File: history.png (41KB, 574x331px) Image search: [iqdb] [SauceNao] [Google]
history.png
41KB, 574x331px
NEW THREAD AT >>51562843

NEW THREAD AT >>51562843
>>
>>51562786
Have fun with that. Nothing brings me more dread than knowing I need to deal with my ISP's customer service for any reason.
>>
>>51562762
Oh and prehaps you want to guard against peeking on an empty list. so do
 public E peek() {
if (list.length > 0){
return list[0];
}
else{
return null; //Or throw exeception? Dunno what the desired behavior is.
}
}
>>
>>51562878
p.s. This is how you'd want to develop your code. Make something simple and realize the issues with it. Don't try and just throw everything in there at once unless you're comfortable with it. In this case most people would probably be fine with writing this second version from the get go but whatever suits you is fine.
>>
>>51562757
>do my homework for me wahh
>>
Is there a relatively fast way to create a list of every possible subsequence in sequence?

The only way I've figured out so far is to just go through each element in the sequence and add that element to the list, then add that element + every other element, recur/iterate etc.
Maybe it's just me but it seems like I'm missing a better way of doing it. Is there a more clever way to approach this that I'm missing?
>>
>>51563010
Honestly think he's just trolling.
>All caps
>someone "told him" not to use an array
>really really bad code considering what's being attempted.
>>
>>51563051
There isn't an efficient way to find all permutations
>>
>>51563107
or a fast way, rather
think it's O(k. n!)
>>
>>51563051
Recursion is a good start, once you have that you should save all subsequences you calculate in memory. Since subsequences might repeat, you can avoid having to calculate the same thing twice or even ten times.
>>
>>51562678
Could I get some help please?
>>
>>51563368
you called next() when there wasn't any more items in the iterator. You need to check hasNext() first before you call next().
>>
Let me explain something to the retards that say lisp us bad because parentheses :

print(x)
(print x)

Any difference in the number of parentheses?

Ok, now imagine instead of curly braces there's parentheses.

void foo()
{
print(2);
}

(define (foo)
(print 2))

Still same number
>>
>>51563746
braces make a readable difference between blocks and parameter lists
>>
>>51558140
As elegant it might look, mutual recursion is best avoided when defining types because it makes tends to make theorem proving harder later.
>>
>>51559412
stick to your phone threads faggot
Thread posts: 329
Thread images: 28


[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]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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 4Archive shows an archive of their content. If you need information for a Poster - contact them.