[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: 317
Thread images: 30

File: DPT.png (389KB, 934x1000px) Image search: [Google]
DPT.png
389KB, 934x1000px
Old thread: >>56797467

What are you working on /g/?
>>
first for readable code
>>
>>56800999
i finally got my professor's language installed and working on my machine, so i won't have to spend all my hours working on homework assignments on campus in one of the computer labs, and will be able to program from the comfort of my own hobbit hole

that is all
>>
can someone tell me how to improve my reverse shell?
>inb4 don't use python
I don't want 4000 lines of code so I am using python.

server.py:
http://pastebin.com/JpaaxBAW

client.py:
http://pastebin.com/MEAtHVcY
>>
>>56801056
don't use python
>>
>>56801058
What language should I use?
>>
>>56801063
scheme. i have a love hate relationship with scheme. it's elegant and very simple, though. it's very conducive to teaching you how to be a good programmer. i'm also going to be heavily involved in artificial intelligence for until i graduate, and i recently learned the AI community really is fond of it so there's that
>>
>>56801063
java
>>
>>56800999
My first Django Channels app, an online tournament system for "esports". I forgot how annoying learning new frameworks are though.
>>
>>56801083
but is it good for what I need to do right now? No? ok.
>>56801095
no
>>
>>56801063
lua
>>
>>56800992
b,a = a,b
>>
>>56801111
mind if I check these?
>>
File: guido.jpg (97KB, 659x592px) Image search: [Google]
guido.jpg
97KB, 659x592px
>>56801121
Feel free.
>>
>>56801111
Perl has something similar, though idk which came first
($a, $b) = ($b, $a);
>>
>>56801129
thanks
>>
Letting Visual Studio 2015 process through a BigInteger prime.
>>
>>56801106
scheme's 100 times more ideal than python for what you're doing right now

because python is for plebeians and scheme is the thinking man's language

oh wait, that means you should use python myb
>>
>>56801142
you're right. Now can someone who isn't a retard help me. I really would appreciate some feed back on my program.
>>56801056
>>
>>56801069
I feel this is clearer
#!/bin/bash

for image in "$@" ; do
timestamp="$(shuf -i 1400000000000-1469999999999 -n 1)"
extension=${image##*.}
filename="$timestamp.$extension"
while [ -f "filename" ] ; do
timestamp="$(shuf -i 1400000000000-1469999999999 -n 1)"
filename="$timestamp.$extension"
done
mv "$image" "$filename"
done
>>
>>56801056
too many newlines
>>
>>56801056
>conn.setblocking(1)
I thought blocking sockets was the default?

Anyway, what do you mean "improve"? Looks fine to me. Do you want feature suggestions?
>>
File: 1474591686192.gif (3MB, 252x350px) Image search: [Google]
1474591686192.gif
3MB, 252x350px
>>56801270
Python3 is different when it comes to socket shit. Also yea, I do want feature suggestions.
>>
File: bullshit exercise.png (11KB, 195x333px) Image search: [Google]
bullshit exercise.png
11KB, 195x333px
wtf you fucking bird
i'm going to fucking stab YOU
>>
>>56801364
this was way beyond the regular crow
this must be the work of an impersonator

who are you and what did you do with real crow guy
>>
>>56798201
putStrLn . unlines . sort . words =<< getLine
>>
>>56801597
=<
>>
>>56801622
((.).(.))
>>
File: xz45L.jpg (120KB, 1180x552px) Image search: [Google]
xz45L.jpg
120KB, 1180x552px
im trying to solve this stupid question. this is my code
public class stairs3
{
public static void main(String[]args)
{
for (int A =1; A<=5; A++)
{
if (A ==1)
{
numspace();
head();
numspace();
wall();

numspace();
body();
numspace();
wall();

numspace();
legs();
numspace();
wall();
}
if (A == 2)
{

}
if (A == 3)
{

}
if (A == 4)
{

}
if (A == 5)
{

}
}
System.out.println("********************************");
}
public static void head()
{
System.out.print(" o *******");
}
public static void body()
{
System.out.print("/ | \\* ");
}
public static void legs()
{
System.out.print(" / \\ * ");
}
public static void wall()
{
System.out.println("*");
}
public static void numSpaces(int spaces)
{
for (int i = 1; 1 ; i++)
System.out.print(" ");
}
}
>>
>>56801645
This is totally a crow question
>>
File: AAAAAAAAAAAAAA.gif (337KB, 640x360px) Image search: [Google]
AAAAAAAAAAAAAA.gif
337KB, 640x360px
>>56801021
I saved this image the other day for reposting and I accidentally scrolled over it in the GTK open file dialog. By attempting to generate a preview, it crashed my browser and xfce along with it.
>>
File: jew.png (14KB, 692x759px) Image search: [Google]
jew.png
14KB, 692x759px
I want a prize for worst code with passable output.
#triangle.py
from sys import argv
size = 2*int(argv[1])+1
lines = size-2

triangle = []
for line in range(1, lines):
triangle.append((lines-line-1)*' ' + (2*line-1)*'*')

upside_down_triangle = triangle[:]
upside_down_triangle.reverse()

jew = []
cutoff = lines/4

for line in range(0, cutoff-1):
jew.append(triangle[line])
for line in range(cutoff, lines-cutoff-1):
if len(triangle[line]) > len(upside_down_triangle[line]):
jew.append(triangle[line])
else:
jew.append(upside_down_triangle[line])
for line in range(lines-cutoff, lines-1):
jew.append(upside_down_triangle[line])

for line in jew:
print(line)
>>
>>56801660
welp. i guess i will make a civil rights movement on coding rights
>>
>>56801687
This is way better than the shit I produced
>>
>>56801687
>jew = []
>>
File: 1443537615476.gif (245KB, 500x500px) Image search: [Google]
1443537615476.gif
245KB, 500x500px
I have to show off some string methods in java.

What kind of methods should I run? The more methods I do, the more sextra credit I get.

Let's not go overboard tho I'm still a beginner.

So let's say a user inputs their name John David Eisenhower, what kind of cool tricks can I do?
>>
>>56801706
s.toLowerCase(), guaranteed top marks
>>
>>56801706
What do you mean? Use existing methods or write your own?
>>
>>56801706
s.reverse()
s.anagram()
s.memset(0)
strrev

strfry
>>
>>56801706
Palindrome check is a classic.
>>
>>56801706
Check if a given string refers to a shit waifu
>>
>>56801740
oh if I can write my own that would b laff.

>>56801725
>>56801747
>>56801764
yep these all check out. Far out lads.

I'm a cute anime slut for all of u bois now.
>>
>>56800999
Why do you people love this image so much?

come up with something original and not shit
>>
>>56801856
i'll try to make ops with gooks tomorrow
please anticipate it
>>
File: 1448035134967.jpg (9KB, 300x222px) Image search: [Google]
1448035134967.jpg
9KB, 300x222px
>>56801856
um, we've been using this image for years.

pls go before I unleash this loli on u
>>
>>56801856
>DRY
Fuck you
>>
>>56801645
PLZ HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>>
Will rainbow stocking really help my code?
>>
>>56801879
I'm partial to black kneesocks myself.
>>
File: 1402456072275.jpg (8KB, 273x276px) Image search: [Google]
1402456072275.jpg
8KB, 273x276px
>>56801801
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
>>
File: wow dude.jpg (178KB, 934x1000px) Image search: [Google]
wow dude.jpg
178KB, 934x1000px
>>56801856
do you like my new DPT image?
>>
File: 1450214166479.jpg (58KB, 500x487px) Image search: [Google]
1450214166479.jpg
58KB, 500x487px
>>56801876
im not gud enough to help u but I hope some1 does

rooting 4 u
>>
>>56801914
Thanks and its due tomorrow fuck java
>>
daily reminder that anime is for nerds
>>
File: aoba code monkey.jpg (174KB, 1280x720px) Image search: [Google]
aoba code monkey.jpg
174KB, 1280x720px
>>56801935
yes?
so is programming
anime and software engineering go hand in hand
>>
>>56801974
programming is for everyone, nerd
*beats you up*
>>
>>56801645
Make a class constant and set it to 1. Modify the code to make it properly print a single level staircase using the constant. Then change it to 2, see what's fucked up and fix the code so that prints a 2 level staircase. Try changing to 3 and it should work fine.

Basically, start at a fixed level, then figure out how to scale/repeat it to make larger/smaller levels
>>
what's a first good app to make besides the stuff you learn in books and school?

I'm thinking maybe something like a calculator, something practical
>>
>>56802030
imageboard
>>
>>56802030
>what's a first good app to make besides the stuff you learn in books and school?
>I'm thinking maybe something like a calculator
wew
>>
>>56802044
That might be too easy which is why I used it as a crappy example in hopes of you giving me a better one
>>
>>56801083
Thanks for the heads up. I will get started on learning it now.
>>
>>56801645
Thanks for the exercise.
puts s = mapM_ putStrLn s

man = [" O ******",
"/|\\ * ",
"/ \\ * "]

row l r = map line man
where line str = concat [" ", sl, str, sr, "*"]
sl = replicate l ' '; sr = replicate r ' '

stairs n = concatMap step [0..n] ++ [bottom]
where step i = row (5 * (n-i)) (5 * i)
bottom = replicate (n * 5 + 12) '*'


*Main> puts $ stairs 0
O *******
/|\ * *
/ \ * *
************
*Main> puts $ stairs 5
O *******
/|\ * *
/ \ * *
O ****** *
/|\ * *
/ \ * *
O ****** *
/|\ * *
/ \ * *
O ****** *
/|\ * *
/ \ * *
O ****** *
/|\ * *
/ \ * *
O ****** *
/|\ * *
/ \ * *
*************************************
>>
>>56802065
make whatever you want, mate

I like to scrape websites so I do that
At one point I wanted to make a videogame so I did that
I like reading harry potter so I designed a number of tools for archiving websites I wanted to read offline

I have been programming for a year now, I started out with statistics and text-based games though so maybe there's your beginning
>>
>>56801935
Not only does anime go hand in hand with programming it also makes you better programmer.
>>
>>56802146
did you do it on java? if so can i please have the code
>>
Has anyone ever worked with the eclipse plugin api? If I were to track stuff like user entered variables and fields, how would I go about doing that?
>>
>>56802156
Fuck no, why would I subject myself to Java?
>>
>>56802146
nice
>>
>>56800999
CCTV/DVR box firmware from scratch. Too many decent boxes with shit firmware out there.
>>
>>56802156
>is that in java
>can I have the code
>>
>>56802146
reminds me of bottle.pl
>>
>>56802146
using ; in haskell instead of newline
Whats the world coming to...
>>
>>56802185
my first guess was python. but maybe he read my code.
>>
>>56802156
>>56802252

It's Haskell, and Anon has posted all of the code associated with it.
>>
What is the difference between input.next() and input.nextLine()? Both can be used for Strings but what is the difference?
>>
How do you guys go about designing code/programs? Do you use any particular modelling/design methods or do you just use rough block diagramming + notes?
>>
>>56802340
I usually just try to do it in small chunks but if it is sufficiently complex i draw diagrams on paper mixture of my own UML and flow charts...
>>
>>56802340
I just read datasheets and try to translate what I see there into what a compiler/etc expects.
Currently dealing with embedded dev, fun shit, that.
>>
>>56802340
I do it in my head. If i need to write it down, i code it.
>>
And cleaned up to be more readable:

puts s = mapM_ putStrLn s

man = [" O ******",
"/|\\ * ",
"/ \\ * "]

stairs n = concatMap step [0..n] ++ [bottom]
where
step i = map (line (n-i) i) man
line l r s = concat [" ", spc l, s, spc r, "*"]
spc n = replicate (5*n) ' '
bottom = replicate (5*n + 12) '*'
>>
>>56800999
Messing with WCF, truly a pain in the ass to only get it ready.
>>56802340
I just think about the classes (objects) that will be useful and start implementing from that, I also like to keep a Word document for the functionality that I need to implement in the future.
>>
>>56802378
puts = mapM_ putStrLn
>>
>>56802396
*Main> :r
[1 of 1] Compiling Main ( stairs.hs, interpreted )

stairs.hs:1:8:
No instance for (Foldable t0) arising from a use of ‘mapM_’

The type variable ‘t0’ isis ambiguous
Relevant bindings include
puts :: t0 String -> IO () (bound at stairs.hs:1:1)
Note: there are several potential instances:
instance Foldable (Either a) -- Defined in ‘Data.Foldable’

instance Foldable Data.Proxy.Proxy -- Defined in ‘Data.Foldable’

instance GHC.Arr.Ix i => Foldable (GHC.Arr.Array i)
-- Defined in ‘Data.Foldable’

...plus three others
In the expression: mapM_ putStrLn
In an equation for ‘puts’: puts = = mapM_ putStrLn
Failed, modules loaded: none.
>>
>>56802408
>isis ambiguous
Is Haskell a terrorist language?
>>
>>56802416
My dear anon you have discovered a bug! Now you can say to contributed to ghc
>>
>>56802408
I assume this is MonomorphismRestriction
>>
>>56802416
I'm not sure what's up with my GHC error messages. Shows up whatever version I ask stack to give me. Maybe a Windows issue?

>>56802428
mapM_ is too general, there's not enough information to deduce that I want t0 = [], which I assume defaulting takes care of or something I dunno.
>>
python is fun
>>
>>56802340
Mostly, I just do it in my head.

If I need to write an algorithm or I have trouble visualizing it, I get out some graph paper and step through the function manually.
>>
>>56802444
That it is. I mostly just use it when dealing with funny usb devices without linux support. easy to talk back and forth with them using either pyusb or python-cython-hidapi
>>
>>56802440
I mean why it doesn't infer the type to be
Foldable t => t String -> IO ()
>>
>>56802458
Oh, you're right, it's the MR. Adding the right pragma makes the compiler accept it.
>>
>>56802444
Yeah, I love how prototyping in python is so fast and easy, it's almost like writing pseudocode. I use it for probably two thirds of my code.
>>
>>56802444
>>56802456
>>56802477
Fuck off Guido
>>
File: 1474684910881.jpg (33KB, 419x419px) Image search: [Google]
1474684910881.jpg
33KB, 419x419px
>>56802456
wut about sockets
>>
>>56802478
Just because you haven't been enlightened by the snek, doesn't mean you have to take out your frustrations on us you meanie-bo-beanie
>>
>>56802478
I primarily use c languages. python I just use to interactively talk to devices for the sake of reverse engineering their usb/hid protocols.
>>
>>56802483
I don't currently have a need for them, either in python or c/etc, so no idea.
Also, how do you do those nice code blocks on here?
>>
>>56802499
>enlightened
>by a language for 3 year olds
>>
>>56802499
The name `Python` comes from Monty Python, not the snake...
>>
>>56802529
lets see you bind to an IP in C
>>
>>56802529
This thread was doing so good with only hating on Java...
>>
>>56802548
Ok? A python is still a snek
>>
>>56802548
Yep. spam, eggs instead of foo, bar
>>
>>56802444
>tfw recruiters don't like python
>>
File: 1474859223079.jpg (146KB, 500x375px) Image search: [Google]
1474859223079.jpg
146KB, 500x375px
>>56802574
>tfw someone says some retarded shit
>>
Are we being fucking raided by /vg/ or something?
What's with all these snake fags?
>>
>>56802613
Dunno.
>>
time to learn c#!
>>
>>56802636
You fell for the meme
>>
>>56802613
Why would people who use python be in /vg/?
>>
>>56802529
reminds me of this yuppie afterschool learning center thing for rich white peoples' kids near where i live, and there's a sign in the window that says "python coding for kids". i saw it and thought "yeah i bet those parents will be real proud when their kid ends up making shitty eroge dating sims"
>>
>>56802662
I am using it for its WPF lib

I am not fond of C++ or C so C# was a good compromise I think
>>
>>56802668
amateur game dev general
>>
>>56802704
If you are developing games in python you are a fucking retard.
>>
File: pih.jpg (966KB, 1012x1345px) Image search: [Google]
pih.jpg
966KB, 1012x1345px
So I'm learning Haskell out of pic related, and I'm on the applicatives section. Here's an example the book gives

instance Applicative Maybe where
-- pure :: a -> Maybe a
pure = Just

-- (<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b
Nothing <*> _ = Nothing
(Just g) <*> mx = fmap g mx

-- returns Just 3
pure (+1) <*> Just 1 <*> Just 2


My only question is, why does the function need to be wrapped as well? I think I understand how applicatives work, it's more of a question of why?
>>
>>56802730
What possible reason could you have for learning haskell. Python would be 1000 times better for whatever you need.
>>
>>56802730
I'm not sure what you are asking? Is your question: Why does function operating on monads need to be monadic?
>>
>>56802724
if you are developing _ in python you are a fucking retard
>>
is it true that haskell programmers are literally too smart to be employed?
>>
>>56802738
Yes let anon learn nothing new especially different paradigm. What benefit would he have from learning something different i wonder?
>>
>>56802730
>why does the function need to be wrapped
Sort of so you get the same behaviour in the function

For instance
ZipList [f,g,h] <*> ZipList [x,y,z] = ZipList [f x, g y, h z]
[f,g,h] <*> [x,y,z] = [f x, g x, h x, f y, g y, h y, f z, g z, h z ]
Nothing <*> Just x = Nothing

etc
>>
>>56802741
Basically, why
pure (+1) <*> Just 1 <*> Just 2

instead of
(+1) <*> Just 1 <*> Just 2


I haven't gotten to monads yet, so I can't answer your question
>>
>>56802730
>>56802766
And one reason you'd do this is so you've got currying within the applicative

pure MyFunc <*> a <*> b <*> c
or
MyFunc <$> a <*> b <*> c
>>
>>56802754
Let me list all the benefits of learning haskell
>No job wants/needs haskell
>its not a good for scripts so it wont be useful for daily tasks
>has no advantages over any other language
>it's functional
Damn, after listing all those advantages, maybe I should pick up haskell
>>
>>56802776
That's what fmap (<$>) does
There are some examples >>56802766
It lets you apply a function within the applicative

It's related to the concept of a monoidal category


>>56802738
Python is trash, don't fool yourself
>>
>>56802782
Well then what are you doing here instead earning your precious money kike.
As if there are no benefits in learning itself let alone different paradigm but yea focus on not having jobs in a language.
>>
>>56802796
What benefits? Please enlighten me.
>>
>>56802789
You havent actually answered his question.
Why do you need to wrap +1 in Pure?
>>
>>56802789
Python can do anything haskell can do except better buddy.
>>
>>56802818
Yes god forbid we should learn and become smarter. We should just program and do one thing, never think anything different, do anything different. We must only be wage slaves with no inquisitive or original thoughts.
>>
>>56802822
pure x <*>
is equivalent to
x <$>


>>56802826
This is some quality bait
>>
Can someone explain to me what lambdas are? Im afraid im an idiot.
>>
>>56802836
neat, thanks. Still not exactly sure as to why
>>
>>56802840
A cute name for anonymous functions.
>>
>>56802834
>Yea god forbid we should learn and become smarter.
Learning python can teach you a whole lot. You still haven't given me one advantage.
>>56802836
name something you can do in haskell that you can't do in python.
>>
>>56802840
Function literal

>>56802845
pure x <*> vs x <$> is a style choice, but <*> itself is not the same as <$>

there are examples of using <*> here >>56802766
<*> can provide sequencing too, and gives rise to *>
monadic >> is generally the same as applicative *>
>>
>>56802789
>>56802836
Maybe I need study it mroe, but I'm just not wrapping my head around applicatives and I'm not even sure which part is giving me issues. Thanks for the help though.
>>
>>56802776
*Main Control.Applicative> let fs = [(+3), (*2), negate]
*Main Control.Applicative> let xs = [2, 3, 4]
*Main Control.Applicative> fs <*> xs
[5,6,7,4,6,8,-2,-3,-4]
*Main Control.Applicative> ZipList fs <*> ZipList xs
ZipList {getZipList = [5,6,-4]}


You can't do these with pure+<*> (which is equivalent to fmap) because the functions themselves as lifted.

pure negate is [negate] in the list Applicative and ZipList (repeat negate) in ZipList, but you can have other Applicative function values that aren't just a single pure function lifted into the functor, like fs and ZipList fs shown above.
>>
>>56802870
>name something you can do in haskell that you can't do in python.
1. Strong expressive static type system
2. Reasonably performant code that isn't a C call
3. Nice syntax, not poorly thought out sugar
4. Purity. First class manipulation of effects.
>>
>>56801129
>HERP DERP FORCED STYLE
>HERP DERP WHITESPACE MATTERS
>HERP DERP FORCE EVERYONE TO WRITE BABBY TIER CODE
shit tier language
>>
>>56802870
python doesnt require any new way of thinking. Its exactly the same in that sense as any other oop/imperative language. Syntax and libraries are different thats all. On the other hand functional programming is completely different way of approaching problems in general hence much more worth wile learning even tho it might not have immediate benefit in terms of $$
>>
>>56802840
An anonymous function you can pass as an argument or save as a variable.
It's the idea of code as data.
They allow you to build powerful abstractions, such as closures.
>>
>>56802870
Have the compiler tell me when I make mistakes.
>>
Personally I find python odd because of the fact its sensitive to tabs vs spaces and doesn't have any close to its methods and such.
>>
>>56802608
b-but they don't
>>
weird request, but could someone pastebin their Python.sublime-package file for sublime 3? Mine is corrupted
>>
>>56802890
>static vs dynamic is a preference, not an advantage.
>python i a scripting language, it performs perfectly fine when it comes to scripts
>again, another opinion
>useless, this does not help me do anything productive
>>56802893
I would think learning the matplotlib module is would require a different way of thinking then learning the socket module.
>>56802896
Don't make mistakes stupid.
>>
>>56802890
>Nice syntax, not poorly thought out sugar
kek, python syntax is definitely bad but that doesn't make haskell syntax good fampai
>>
>>56802956
I don't. The compiler doesn't let me.
>>
>>56802956
>I would think learning the matplotlib module is would require a different way of thinking then learning the socket module.

Have you tried actually solving something with pure func style? You would see its different on much larger scale. It forces you to approach problems from different perspective while some library really doesnt. Aslo thats argument for any math lib not python per se
>>
>>56802956
Who are you quoting?
>preference
It's not a preference, there is a distinct advantage to static typing. Haskell even has a data.dynamic package in base that you can use for dynamic types if you need them.

You can put dynamic types in a static language but not the other way around.

>a scripting language
Hang on anon, you're trying to sell this language to me, remember?

>opinion
__init__ and others for a start

>useless
Not at all.


>>56802958
Do you use Haskell?
>>
File: 1398978680080.jpg (156KB, 1440x1080px) Image search: [Google]
1398978680080.jpg
156KB, 1440x1080px
>CS class
>turn in procedure for the files are harder than the assignments

It's like I'm in a class stuck in the 90s.
>>
Ok so what I have gathered from observing this Haskell vs Python fight. Python can do stuff but it is easy so you guys don't like it. Haskell is good for... nothing. But it makes you smarter.
>>
>>56802989
My biggest gripe with python is its type system and performance. God is it slow, for anything but small projects you probably want to use anything else.
Thats not saying haskell is good but as func prog its make you think differently which is in it self good,
>>
>>56802989
>Ok so what I'm gathering
You've never been to this thread before today, have you?
You just came here and started shilling Python.
Oh wait, I mean you totally weren't one of the guys arguing that Python is better than Haskell in every way. You are just "observing".
>>
>>56802999
>My biggest gripe with python is its type system and performance

>python's type system
>python's performance

Don't worry anon, NEITHER of those actually exist!
So you've got no problems with Python!
>>
>>56802985
So what your saying is, the good thing about static typed languages, is that you can put dynamic types in it? And yes, python is a scripting language. I use python daily and thats what makes it useful. I can do anything from a reverse shell to file handling in under 300 lines of code and it runs perfectly.
>>
>>56803012
>Muh funcshunel programming
>Muh static typing
>Muh differeny thinking
Yeah take a few deep breaths you sperg and then go back to compiling your kernel
>>
>>56801700
>jew = [[[]]]
>>
>>56803026
same can be said for perl...
>>
>>56803026
>So what your saying is, the good thing about static typed languages, is that you can put dynamic types in it?
No you idiot, I'm saying that because you can put dynamic types in a static language but not the other way around, that there is LITERALLY no benefit to dynamic languages and that static typing can only be AS GOOD or better (which it is)

Haskell is also known for concise solutions
>>
>>56803012
I wasn't, I don't care for either of the languages. But the only thing people are saying about haskell is it makes you think differently which imho is pretty useless. If I am going to use a language, I want it to do something, I don't just want to sit and solve problems all day. Thats why I use C
also this>>56803035
is not me
>>
>>56803039
ok? What does that have to do with anything?
>>
>>56803048
i thought solving problems was what programming is about...
>>
>>56802972
>It forces you to approach problems from different perspective while some library really doesnt
>implying haskell doesn't have libraries
>implying "import" programming isn't a potential problem in any language

>>56802985
>Do you use Haskell?
no, because i have no reason to. i write realtime software which hinges on mutable state and is naturally less intuitive in FP languages. plus, i have all the FP-style functionality i would ever want in C++, a language i much prefer anyway, with things like generalized constexpr, generic lambdas, and templates/specialization
>>
>>56803057
I thought programming was to achieve a goal, and to achieve that goal you have to solve problems.
>>
>>56803057
Yep. Which is why I only use python when fiddling with that usb shit. its simple to send and recieve data for the purpose of understanding them, then I can get down to my real work in a language I prefer.
>>
>>56803048
One person has been saying that

There are a lot of benefits to Haskell, e.g. the ones I listed here >>56802890


>>56803060
>no
>C++
> FP-style functionality ... in C++
You clearly aren't in a position to say what would be good syntax for Haskell then.
It would be fucking retarded for Haskell to add a for loop as a language feature, for instance.
>>
>>56803041
>Haskell is also known for concise solutions
Solutions to what? Project Euluer questions? I still find that language pretty useless in terms of making something useful. I guess it does make you approach problems in different ways and encourages you to think but thats about it. I just think python is better because you can make something useful and learn something in the process.
>>
>>56803087
A lot of things, actually.
I've heard more than one example of someone moving their code base from an imperative language to a functional language and reducing the size by a factor of 10 or more.
>>
>>56803093
Can I have one example, because I can give you a bunch of them for python?
>>
>>56803083
>You clearly aren't in a position to say what would be good syntax for Haskell then
i couldn't tell you what would be good, because i don't know if it even could be. i understand that it's a natural representation of the underlying math. my point is that the underlying math is relatively unintuitive

>It would be fucking retarded for Haskell to add a for loop as a language feature, for instance
why is that? you can use a for loop in a pure constexpr function in C++. how come C++ can be multiparadigm without bending over backwards but haskell can't? maybe you see why i consider it more intuitive?
>>
>>56803069
Yeah, rapid prototyping and quick utilities are where python shines. Consider the following:
>I need a tool to convert some proprietary file format to something I can understand.
Python: 2 hours to code, 1 hour to run
C: 4 hours to code, 5 minutes to run

Assuming you will rarely run this software, Python suddenly becomes interesting. It has quick turnout and it's easy to improve iteratively as you fail. Plus, once you have your python code, it's not too difficult to convert it to C or to something else that's more performant.

Personally, I'm partial to lua: it's way faster than python (luajit is on par with C#, that's pretty good for managed code), and it's not an OO language! Although, the standard library is tiny.
>>
>>56803100
There aren't very many for Haskell, but you can tell of the reduction by looking at other FP languages like F# and Ocaml that are more popular and more widely used
Haskell is really not very widely used at all, it's even less popular than you'd think

>>56803116
>why is that
It's a library feature.
>>
>>56803122
I'm also big lover of lua but how do you use it in same sense as python. I hate python but still use it when i need something quick and dirty since it does have libraries.
>>
Ok so haskell is good for learning and python is a handy tool. Is that it?
>>
>>56803168
I would agree with that. I personally like haskell but i have never and probably wont use it in a real project
>>
>>56803100
https://youtu.be/FGQAP0GxlW8?t=24m12s
Seek to 24:12 and listen to the anecdote.
>>
>>56803146
Basically for scripting. I rarely end up needing the extra features unless I'm getting fancy, and lua's speed and size means that I often find it way easier to ship lua than I would with python. So if a shell script isn't gonna cut it but I don't need C, I'll pick lua. I don't shy away from python when I need the stdlib, though. And perl is still king for filtering text.
>>
>>56803139
https://github.com/mccutchen/funcgeo
has the same thing in python haskell and a lisp

https://wiki.haskell.org/Blog_articles/Comparisons#Python
Has some haskell / python comparisons (the first link is python wiki's comparison article)


>>56803168
Haskell is an extremely nice general purpose programming language. If you really don't mind dynamic typing, I'm sure Python's fine.
>>
>>56803198
https://www.youtube.com/watch?v=73O7tATQ8og
>>
>>56803122
Yep. I almost never actually write python code, though. Just use its interactive shell.
Only python 'software' (using the term loosely) is a small scriptlet that rebinds (hardware-level) my keyboard's macro keys to f13-18, so I can use xmodmap/etc to bind those. Otherwise, the macro keys send 1-6 by default, which is useless and you can't easily tell those keypresses from the normal 1-6
>>
>>56803168
python is a handy tool only for projects that don't require performance
for example web-based projects

>>56803198
wow this is actually pretty good

nicely done
>>
>>56803198
>for (int a = 1; a <= 5; a++) {
> if (a == 1) { ... }
> if (a == 2) { ... }
> ...
> if (a == 5) { ... }
>}

I do not have a suitable reaction image for this.

Are you trying to be brain-dead? Because you're doing it pretty good.
>>
>>56803198
Here guy, I improved your code:
public class WhoGivesAFuck {
public static void main(String[] args) {
System.out.println(" O *******");
System.out.println(" /|\ * *");
System.out.println(" / \ * *");
System.out.println(" O ****** *");
System.out.println(" /|\ * *");
System.out.println(" / \ * *");
System.out.println(" O ****** *");
System.out.println(" /|\ * *");
System.out.println(" / \ * *");
System.out.println(" O ****** *");
System.out.println(" /|\ * *");
System.out.println(" / \ * *");
System.out.println(" O ****** *");
System.out.println(" /|\ * *");
System.out.println(" / \ * *");
System.out.println("********************************");
}
}


It's been a while since I've done any Java so I'm not sure if it's all good or not.
>>
>>56803244
You should try haskell, it apparently boosts brain power.
>>
>>56803244
>>use a class constant that makes it possible to change the number of steps

why didn't you just do 1 println anyway
>>
>>56803255
He tried to be cool but ended up looking stupid
>>
>>56803255
>class constant
His doesn't either.
>>
>>56803260
>Java
I don't think he was trying to be cool
>>
Is it worth it learn Assembly?
>>
>>56803284
Well obviously from reading this thread you should never learn anything new that isnt immediately useful and doesnt bring $$. So no...
>>
>>56803253
But anon, I already wrote the the solution in Haskell and used it to print out those lines so I could slap it into an editor and vomit Java over it real quick.
>>
>>56803284
Only good for debugging, reverse engineering, writing an OS or a compiler
If you're not doing any of those, I'd say no
>>56803253
>>56803294
Jesus, what are you so salty about
>>
>>56803284
Depends on what you're doing. Good for embedded.
>>
>>56803294
Lol salty bitch
>>56803284
Assembly is a great USEFUL language, unlike some.. *cough haskell cough*. If you learn assembly you can literally do anything.
>>
File: 1468529886730.gif (499KB, 450x296px) Image search: [Google]
1468529886730.gif
499KB, 450x296px
>>56803307
>unlike some.. *cough haskell cough*.
*coughs behind you*
heh, nice try... kid
>>
>>56803313
I don't get it.
>>
>>56803307
*anything on silicon that supports the opcodes you learned
But yeah, asm is pretty damned nice.
>>
>>56803294
haha are you mad about my haskell comment? That was just banter, relax

>>56803316
lurk more then eh
>>
>>56803204
らきすた my nigga これのアニメがバッチグね。

>>56803222
how about i put // in front and remove the end bracket for you.

>>56803221
Thanks mate couldn't of done it without a higher java students assistance.

>>56803244
You need spaces.
>>
>>56803307
>>56803313
Wow they're literally gaging on their favorite code's cock
>>
>>56803316
Fedora adorned
Man flips o'er decored table
The conclusion reached
>>
I must be hopelessly bored, because I translated my Haskell stairs into Java. I don't understand the appeal of imperative programming, it's so fiddly and verbose.

Also I don't have a javac around, so /dpt/ will have to debug it for me.

class Stairs {
static void main(String[] args) {
new Stairs().stairs(Integer.parseInt(args[0]));
}

void put(String s) {
System.out.print(s);
}

final String[] man =
[" O ******",
"/|\\ * ",
"/ \\ * "];

void stairs(int n) {
for (int i = 0; i <= n; ++i) {
step(n, i);
}
bottom();
}

void step(int n, int i) {
for (int j = 0; j < 3; ++j) {
line(n-i, i, man[j]);
}
}

void line(int l, int r, String s) {
put(" ");
spc(l);
put(s);
spc(r);
put("*");
}

void spc(int n) {
replicate(5*n, " ");
}

void bottom() {
replicate(5*n + 12, "*");
}

void replicate(int n, String s) {
for (int i = 0; i < n; ++i) {
put(s);
}
}
}
>>
>>56803451
its public static main but oh well.
You should just go over to /sci and solve some homeworks thats what i do when bored...
>>
File: triangle.png (25KB, 727x430px) Image search: [Google]
triangle.png
25KB, 727x430px
>>56801687
Do you even list comprehension :^)
#triangle.py
from sys import argv
h = int(argv[1])
x = [s+s[::-1].replace("/","\\")for s in["/".ljust(i).rjust(3*h)for i in range(1,3*h+1)]]
print "\n".join("".join("_" if i[-1]==" "and n+1 in{h,3*h}else i[-1]for i in map(sorted,zip(x,y)))for n,(x,y)in enumerate(zip(x+[" "*6*h]*h,[" "*6*h]*h+[s[3*h:]+s[:3*h]for s in x])))
>>
>>56803563
thats worthy of perl!
>>
>>56803563
cute
>>
>>56803563
Impressive.
>>
>>56801056
>I don't want 4000 lines of code so I am using python.
A program like that would hardly take more lines in C than in python desu famalam.
>>
I hate Java.

public class Stairs {
public static void main(String[] args) {
new Stairs().stairs(Integer.parseInt(args[0]));
}

final String[] man =
{" O ******",
"/|\\ * ",
"/ \\ * "};

void stairs(int n) {
for (int i = 0; i <= n; ++i) {
for (int j = 0; j < 3; ++j) {
put(" ");
put(" ", 5*(n - i));
put(man[j]);
put(" ", 5*i);
put("*\n");
}
}
put("*", 5*n + 12);
put("\n");
}

void put(String s, int n) {
for (int i = 0; i < n; ++i)
put(s);
}

void put(String s) {
System.out.print(s);
}
}
>>
>>56803204
This fucking song is stuck in my head
>>
what book to learn c, then c++?
>>
>>56803732
wait, you can do that?

supply a function with a positional argument and then call another function with only one positional argument (String s) and the original (int n) will get inherited?

I didn't know you could do that in java... that's pretty neat

I am pretty sure python won't do that for you
>>
>>56803784
If you don't know how to program then K&R.

If you're already familiar with programming then just the tutorials on cprogramming.com and cplusplus.com . Consider K&R anyway.

I don't know what book to recommend you for C++ if you don't know programming but have read K&R and learned C. Back in the day Stroustrup's own book was really good but I don't know if it has held up and it's very long so you probably won't read all of it. Try to learn more modern C++. There's a much bigger gap between modern C++ and older "C with classes" style C++ than there is between modern C and older C.
>>
>>56803808
>positional argument
>get inherited
There are two seperate unrelated methods both named put which are disambiguated by the types in the signature. I just happened to call put(String) from within the body of put(String, int)
>>
>>56803843
oh, I see
>>
File: htt.webm (1MB, 852x480px) Image search: [Google]
htt.webm
1MB, 852x480px
/dpt/-chan, daisuki~

>>56803784
C primer plus then accelerated c++

>>56803284
No.

>>56803168
Austin tried haskell has a first programming language but quickly reverted to Java.

>>56802989
Haskell main purpose is to be a academic language for plt research.

>>56802840
Procedures as expressions which is needed for declarative programming where everything must be an expression. Being an expression also implies first class value and anonymization.

>>56802750
Yes

>>56802613
Python is not really popular for game development.

>>56802444
Python is more concerned with making it easy to write good programs than difficult to write bad ones.

>>56802312
next returns the next element while nextLine returns all characters (as a string) till a new line.

>>56802030
chip8 emulator, irc bot, PONG, file shredder, ...

>>56801856
The surrounding ( ) is a reference to Lisp

The fez hat is a reference to Gerald
https://en.wikipedia.org/wiki/Gerald_Jay_Sussman

The book is SICP
https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs

The girl is Yuki Nagato, a programming literate. She is doing a somersault.
https://www.youtube.com/watch?v=ba_sJkWdBLA

>>56801706
Ascii banner.

>>56801687
>((lines-line-1)*' ' + (2*line-1)*'*')
According to /dpt/, * on strings is a sin.

>>56801083
>learned the AI community really is fond of it so there's that
https://news.ycombinator.com/item?id=1803815

>>56801056
You don't need return at the end of a procedure.

>>56800999
Thank you for using an anime image.
>>
>>56803937
(You)
>>
>>56803937
If you're going to do this you have to respond to every post.
>>
>>56803978
why?
>>
File: YunoYandereFace.jpg (126KB, 1280x720px) Image search: [Google]
YunoYandereFace.jpg
126KB, 1280x720px
>>56804020
I wanted to be the first to reply to you senpai
>>
>>56803937
>C primer plus
is there much difference between version 5 and 6? Found a cheap copy of 5
>>
>>56804039
just torrent it and see for yourself. Than support by buying if you like
>>
>>56804039
only have read the 6th which covers c11
>>
>>56804068
oh k, pretty sure 5 covers 99

>>56804051
i might as well yeah
>>
>>56801687
jew = []
...
jew.append...

Kek
>>
Let's say I want to download this image

http://i.4cdn.org/g/1474966274075.jpg


I can open a filestream to it and download the image, like so:

f=requests.Session().get(link, headers={'User-Agent':headers}).content


f now looks like
\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00H\x00H\x00\x00\


I can write that to file like so:

out=codecs.open('boards\\'+name+'\\'+thread_name+'\\'+image_name,'w+',encoding='utf-8')
out.write(str(f.content))
out.close()


I can even truncate the b'' that encloses the output by slicing[:2][:-1]

However when I attempt to open it it's corrupted

What did I mess up? I thought I did everything perfectly but the encoding went wrong at some point
>>
>>56804221
nvm solved

pm me for the fix
>>
>>56804221
use binary mode.
>>
>>56803563

What font?
>>
File: nvmnotabug.jpg (117KB, 1531x847px) Image search: [Google]
nvmnotabug.jpg
117KB, 1531x847px
>>56800999

>mfw learning bash and i thought i found bug on 4chan/g/ with a script that parses images in a thread
>mfw thought i was onto something then realize my mistake
>mfw i didn't have anything to check for cases where people had i.4cdn.org in the image title itself

http://sprunge.us/KjVC

dpiup(){
curl --silent --compressed $1 |
tr "\"" "\n" | grep -i "i.4cdn.org" |
uniq |
awk '{print "https:"$0}'
}


it's frustrating as fuck sometimes because the syntax looks like a giant blob of backslashes.
>>
>>56804304
huh

well I finished my image scraper anyways

it's for a different chan but rather simple

http://pastebin.com/by6dEgTz

These things never require much thought
>>
>>56804400

Bash syntax is gross. Don't use it for large scripts if you can avoid it.
>>
File: computerstate.jpg (77KB, 1920x1080px) Image search: [Google]
computerstate.jpg
77KB, 1920x1080px
>>56804427
f=open('boards\\'+name+'\\'+thread_name+'\\'+image_name,'wb')


'wb' is for opening a file in binary write mode.

https://docs.python.org/3.7/reference/compound_stmts.html#the-with-statement

with open('boards\\'+name+'\\'+thread_name+'\\'+image_name,'wb') as f:
f.write(img.content)
>>
Is it even possible to JIT x86 to another architecture?
I know how various bytecode languages like Java, C#, Python etc are JIT compiled because they can easily be.
But I have high doubts that x86 code (discluding kernel mode code, that can be solved with traps anyway) can be JIT compiled to other architectures, it doesn't make sense to me. It would invalidate any and all jumps due to the different instruction length.
Another question is, where the hell do you store the compiled code? behind the caches? what if caching isn't enabled?
>>
File: jWWPolf.jpg (138KB, 702x768px) Image search: [Google]
jWWPolf.jpg
138KB, 702x768px
>>56804570
Binary translation is something used by many emulators to reach decent performances.

https://en.wikipedia.org/wiki/Binary_translation
>>
>>56804612
Are there any resources for implementing binary translators?
I want to eventually do it for my VM.
>>
>>56804663
Virtual Machines: Versatile Platforms for Systems and Processes
>>
>>56804685
Ah, I already have that book, thanks.
>>
>>56803198
        static void Main(string[] args)
{
int levels = 8;
int setback = 5;
string[] man = new string[] {
@" O ******",
@"/|\ * ",
@"/ \ * "
};

int limit = (man[0].Length - setback) * (levels+1);

for (int i = levels; i > 0; i--)
{
foreach (string line in man)
{
for (int x = 0; x < (i-1) * (line.Length-setback); x++) Console.Write(' ');
Console.WriteLine(line);
}
}
for (int i = 0; i < limit; i++) Console.Write('*');
}


Doesn't print the wall at the end of the stairs but I don't care enough.
>>
>>56804689
then maybe it's time to read it because binary translation is mentioned as soon as the first pages.
>>
gimme a simple real-world example where using pointers are inevitable
I've only done simple shit in C, want to go advanced
>>
>>56804732
Anything involving strings.
>>
>>56804732
Getting command line arguments.
>>
>>56804735
>>56804738
i was thinking maybe a code snippet or something

I just want to read and understand a program that uses pointers
>>
>>56804732
linked list
>>
>>56804732

Anything involving strings.
Anything involving arrays
Anything involving trees or other linked data structures
Anything involving structs bigger than a register. Just because you can literally copy the entire struct doesn't mean you should.

Basically, literally anything non-trivial.
>>
>>56804741
Fucking look it up
>>
>>56804741
Practically every non-trivial C program will make extensive use of pointers,
Do what >>56804745 says. Linked lists are a pretty good example of using pointers for dynamic data structures,
>>
>>56804748
>Anything involving trees
no.
>>
>>56804741

printf("Hello world!"\n");


This uses pointers.
>>
Is it cheating to look up an algorithm for a project, for example, develop a sort also. Should you write it from scratch or just look it up and plug it in
>>
>>56804766

Implement a Binary Search Tree or an Abstract Syntax Tree without pointers. I dare you.
>>
>>56804772
No. Copying is the first thing you have to learn if you want to become a good programmer..
>>
>>56804772
Just look that shit up. 99% of the time, if someone inexperienced with sorting tries to do it, they will come up with either insertion sort or selection sort, which are pretty crappy algorithms.
>>
>>56801018
what language?
>>
File: anal beads.png (16KB, 397x651px) Image search: [Google]
anal beads.png
16KB, 397x651px
Sweet mother of tits, extending Cortana's voice commands is tedious.

I just want to make her talk lewdly.

They must have done this with the awareness than an erection can only last so long while programming.
>>
>>56804775
and i dare you to look how modern game engines are doing it.

protip

struct Tree
{
Node nodes[MAX_NODES];
uint indexRoot;
}

struct Node
{
uint data;
uint indexLeft;
uint indexRight;
}

parseTree(Tree t)
{

parseNode(Node n)
{
printf("%d\n", n.data);

if (n.indexLeft != NODE_NONE)
parseNode(t.nodes[n.indexLeft]);
if (n.indexRight != NODE_NONE)
parseNode(t.nodes[n.indexRight]);
}

parseNode(t.nodes[t.indexRoot]);
}
>>
>>56804820
>uint indexLeft;
>uint indexRight;
That's unnecessary. For a binary tree implemented using an array (being leftist helps, so there aren't holes, but isn't necessary), you can get the children of node n using (n + 1) * 2 and (n + 1) * 2 - 1.
>>
>>56801063
Hachell ofc
>>
Can someone tell me whether my linkedlist is good
http://pastebin.com/xVD0qrk0
>>
>>56804848

or you can make it more readable by using indexLeft, i really doubt the extra overhead is significant when (n-1)*2 is doing the same thing indexLeft is.
>>
>>56804779
>>56804780

I looked it up. I feel dirty.
>>
>>56804848
yes but then it's no more optimized for memory consumption
>>
>>56805035
>i really doubt the extra overhead is significant
It's 8 bytes per node, which is actually pretty significant.
You're wasting space on your cache lines.
>more readable
It's a simple arithmetic expression, and anybody familiar with binary heaps should be able to identify it immediately. It's not unreadable.
int right = (node + 1) * 2;
int left = right - 1;
>>
File: Captureq.jpg (26KB, 575x199px) Image search: [Google]
Captureq.jpg
26KB, 575x199px
>>56805035
Well if every node has a fixed position you could calculate beforehand which index root->left->left->right has and look it up.
Without going through every node, looking up what node is left, moving there getting the next index, etc.
In big trees that can leave to a lot of page faults jumping around in the tree.
>>
>>56805063
There is absolutely nothing wrong with looking at the literature. Good algorithms take a lot of time to develop and require a lot of expertise.
You're not just going to accidentally stumble onto a good sorting algorithm.
I'm pretty sure everybody expects you to at least look up some sorting algorithms on Wikipedia.
>>
>>56805163
Don't post this shit, you stupid fuck.
A new thread isn't needed for at least 40 posts, and all you're doing is encourage retards to post threads early.
>>
>>56805163
Not for almost another 40 posts.

Why do you always ask this?

Also, what country are you from? It's not an English-speaking country.

>>56800999
Nice trips.

Working on taking code that sort of works and solidifying/error-proofing it. In other words, the most boring part of the project.
>>
>>56805163
>>56805205
>>56805205
>>56805205
whenever
>>
>>56805063
>>56804772
yeah i felt the same when i looked up the quadratic formula, i mean, it just took ~1600 years of mathematics to obtain it so i should have found out by myself, amiright ?
>>
>>56805210
धन्यवाद्
>>
>>56805218

The assignment was to figure out a sort algo and implement it. Part of the question was algo development. a peek at wiki doesn't hurt but does it hinder that part of abstract thinking?
>>
>>56805295
>to figure out a sort algo and implement it
More than likely, they expect you to implement one of the "bad" sorting algorithms (selection sort, insertion sort, bubble sort).
If you just intuit how to sort something, you will almost certainly do one of those.
>>
>>56805218
i don't think it's on the same order of thinking. if you give a human a bunch of numbered cards they will know how to sort them somehow
>>
wish I had infinite time and energy to work out all the problems I want to work on

I think I'd start by making a videogame with the machine learning api google made

fucking life, it just has to screw everything up
>>
>>56805513
You're not going to come up with mergesort on your first try though.
>>
>>56805533
yes. hopefully that's not the exercise though
>>
I'm struggling to decide on good practices for coding WebGL.
Should I have the main function make other functions do all the work of finding and compiling everything, to keep the main function nice and slim?

Also, I'm not entirely sure what this does:

var positionAttributeLocation = gl.getAttribLocation(program, "a_position");
>>
Do some of you have some knowledge with design pattern?
I have to design a little game using design pattern and the overall architecture of the application is suppose to follow the mvc architecture.
I have to make it in java. The game is like a very basic race game. (it doesnt really matter, it's more the design that should be the focus)
What I have trouble with is how and where should I implement ai ? And same question for all the collision.
Also, I want to implement a boost that basically increase the maxspeed of my model for a certain duration.
>>
>>56805582
http://gameprogrammingpatterns.com/contents.html
>>
>>56805568
I'm not entirely sure what you don't understand about that function anon. It's pretty straightforward.

You need to get the vertex attribute location from the shader so you can send your vertex data to it from your program using gl.vertexAttribPointer()
>>
>>56805714
I can't say I understand entirely how vertex data and attributes work.

Multiple attributes should be possible, but it looks like enableVertexAttribArray and vertexAttribPointer were only made to take one attribute as arguments.
>>
>>56805667
I'll read it, thanks.
>>
I'm working on learning Swift to make iphone apps.

Anyone have ideas for practicing at this?
>>
>>56805863
You specify multiple attributes.

>In shader
attribute vec4 pos;
attribute vec2 texCoord;

>In code
gl.getAttriblocation(shader, "pos");
gl.getAttriblocation(shader, "texCoord");
...
gl.vertexAttribPointer(posLoc, 4, gl.FLOAT, false, 24, 0);

gl.vertexAttribPointer(texCoordLoc, 2, gl.FLOAT, false, 24, 16);

I'm not sure what source you are using to learn this but use one that actually explains the rendering pipeline.
>>
>>56806008
Ah, you just repeat all the code.
I should probably make a function for it then.

How do the buffers work when using multiple attributes though?
>>
why is this not working?

 [File: hello/hello.c]
#include <stdio.h>
int main()
{
printf ("hello World\n");
return (0);
}
>>
>>56806139
Problem is not with the code, http://ideone.com/VY0KsV

post the error message you are receiving.
>>
File: m1trpqxno.gif (473KB, 616x900px) Image search: [Google]
m1trpqxno.gif
473KB, 616x900px
Does anyone have that image list of a bunch of (I think 100?) programming projects to do?

I'm brushing up on my C# and need some problems to work on before trying to tackle a bigger project.
>>
>>56806139
Is the text "[File: hello/hello.c]" actually part of the file you're trying to compile, or is that just there because you copied some example code?
Otherwise that is valid and there is probably something wrong with your compiler.
>>
>>56806161
Just use the website instead of shitting up the thread:
http://better-dpt-roll.github.io/
>>
>>56806139
sorry, I raged and forgot to put more info.
I'm new. I don't know about writtin code. a year ago I tried with python, at least I achieved to do something more than a "hello world"
now I'm trying with C, as it seems to be the first basic thing you must learn.
I'm using Geany, as it seems pretty simple to newfags like myself. I used Gedit in the past, but it needs some little changes I do not remember.
I don't know what more should I say. I'm on linux, if it matters.
>>
>>56806179
>>56806152
Post the command you are using to compile and the error message you are receiving, and as >>56806167 points out, in the future put side remarks like the filename as a comment (e.g.
/* [File: hello/hello.c] */
so that the code you post in code tags is an actual working example, so we don't have to ask.
>>
>>56806179
Did you compile your code?
Did the compiler run without errors?
Also what compiler did you use?
>>
New thread, when?
>>
>>56806216
>>56806217

I don't remember not the command, nor the error it gives, at I ragequited yesterday night for not being able of doing a simple task.
I don't know what I'm using as compiler, I use the terminal.
>>
>>56806232
When the thread hits bump limit in about 10 posts.

>>56806161
Feel free to spitball C# questions, I'll be lurking.
>>
>>56806232
when this one reaches page 8 or 9, now fuck off.

>>56806257
Well that makes it hard for us to help you.
When you try again and want help, be sure to post the code, the command you use to compile and the error(s) the compiler prints out.
>>
>>56806280
I'll take care, thanks. I am doing right using the terminal for these things? should I install an emulator or something?
>>
>>56806257
In the terminal, you need to type:
cc -o hello hello.c

this will compile hello.c and output an executable called "hello". Then you can run your program with
./hello


You must run both of those commands inside the "hello" directory where your "hello.c" file is of course. So your terminal might look like:
~/hello$ cc -o hello hello.c
~/hello$ ./hello
hello World
~/hello$
>>
>>56806289
fuck, I'll look for an emulator for C or something. I don't remember having this troubles when I see a little of python.
>>
>>56806287
Yes, no idea what you mean by "emulator", technically the "terminal" is a "terminal emulator" since its not an actual physical terminal but just a program emulating one, but thats probably not what you mean.

In this case a screenshot of what you are doing in the terminal would be very helpful too.
>>
>>56806321
I'll redo all the steps and take notes/screenshots.
thanks for the answer, I was expecting to be insulted.
>>
>>56806316
>emulator for C
Do you mean "interpreter", as in how you type "python hello.py" to execute a Python script?

While these technically exist for C, interpreted C is tiny niche, and if you're looking to learn how to actually program in more than just Python you will absolutely need to get a grasp of using compilers and working in the terminal.
>>
>>56806316
If you want to make your life learning c a little easier, try https://www.tutorialspoint.com/compile_c_online.php
But "learning" C without learning how to use a compiler is stupid.
>>
>>56806348
For now you could try a site like http://ideone.com as mentioned in >>56806152, enter the C program and click Run to compile and run it. Plus if you have any problems you can just post a link to your code.
>>
>>56806401
>>56806379

thanks, I think it's better to redo all the thing again and try to learn what's going on. if I'm failing at "hello world", I need to take more care and find the mistake, instead of doing it easier.
>>
>>56806271
>>56806280
New thread when?
>>
>>56806096
Whichever buffer is bound when you call glVertexAttribPointer is used for that attribute.

Also, look into vertex array objects, which are used to store the vertex attributes so you don't have to call all of that every time you want to draw. I would also suggest against using glGetAttribLocation in favour explicit locations.
>>
>>56806905
>>56806905
>>56806905
>>
>>56804397
Menlo Regular 13pt
>>
>>56802574
Fuck em
Thread posts: 317
Thread images: 30


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