/dpt/ - Daily Programming Thread

Old thread: What are you working on Cred Forums?

Other urls found in this thread:

pastebin.com/JpaaxBAW
pastebin.com/MEAtHVcY
docs.oracle.com/javase/7/docs/api/java/lang/String.html
youtu.be/FGQAP0GxlW8?t=24m12s
github.com/mccutchen/funcgeo
wiki.haskell.org/Blog_articles/Comparisons#Python
youtube.com/watch?v=73O7tATQ8og
en.wikipedia.org/wiki/Gerald_Jay_Sussman
en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs
youtube.com/watch?v=ba_sJkWdBLA
news.ycombinator.com/item?id=1803815
i.4cdn.org/g/1474966274075.jpg
sprunge.us/KjVC
pastebin.com/by6dEgTz
docs.python.org/3.7/reference/compound_stmts.html#the-with-statement
en.wikipedia.org/wiki/Binary_translation
pastebin.com/xVD0qrk0
gameprogrammingpatterns.com/contents.html
ideone.com/VY0KsV
better-dpt-roll.github.io/
tutorialspoint.com/compile_c_online.php
ideone.com
twitter.com/NSFWRedditGif

first for readable code

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

Second for python

delet this

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:
pastebin.com/JpaaxBAW

client.py:
pastebin.com/MEAtHVcY

don't use python

What language should I use?

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

java

My first Django Channels app, an online tournament system for "esports". I forgot how annoying learning new frameworks are though.

but is it good for what I need to do right now? No? ok.
no

lua

b,a = a,b

mind if I check these?

Feel free.

Perl has something similar, though idk which came first
($a, $b) = ($b, $a);

thanks

Letting Visual Studio 2015 process through a BigInteger prime.

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

you're right. Now can someone who isn't a retard help me. I really would appreciate some feed back on my program.

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

too many newlines

>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?

Python3 is different when it comes to socket shit. Also yea, I do want feature suggestions.

wtf you fucking bird
i'm going to fucking stab YOU

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

putStrLn . unlines . sort . words =

Opening this image in another tab in Chrome crashed my entire Ubuntu machine in maybe 10 seconds

=

((.).(.))

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

This is totally a crow question

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.

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)

welp. i guess i will make a civil rights movement on coding rights

This is way better than the shit I produced

>jew = []

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?

s.toLowerCase(), guaranteed top marks

What do you mean? Use existing methods or write your own?

s.reverse()
s.anagram()
s.memset(0)
strrev

strfry

Palindrome check is a classic.

Check if a given string refers to a shit waifu

oh if I can write my own that would b laff.

yep these all check out. Far out lads.

I'm a cute anime slut for all of u bois now.

Why do you people love this image so much?

come up with something original and not shit

i'll try to make ops with gooks tomorrow
please anticipate it

um, we've been using this image for years.

pls go before I unleash this loli on u

>DRY
Fuck you

PLZ HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Will rainbow stocking really help my code?

I'm partial to black kneesocks myself.

docs.oracle.com/javase/7/docs/api/java/lang/String.html

do you like my new DPT image?

im not gud enough to help u but I hope some1 does

rooting 4 u

Thanks and its due tomorrow fuck java

daily reminder that anime is for nerds

yes?
so is programming
anime and software engineering go hand in hand

programming is for everyone, nerd
*beats you up*

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

imageboard

>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

That might be too easy which is why I used it as a crappy example in hopes of you giving me a better one

Thanks for the heads up. I will get started on learning it now.

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 ****** *
/|\ * *
/ \ * *
*************************************

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

Not only does anime go hand in hand with programming it also makes you better programmer.

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?

Fuck no, why would I subject myself to Java?

nice

CCTV/DVR box firmware from scratch. Too many decent boxes with shit firmware out there.

>is that in java
>can I have the code

reminds me of bottle.pl

using ; in haskell instead of newline
Whats the world coming to...

my first guess was python. but maybe he read my code.

It's Haskell, and user 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?

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

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.

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) '*'

Messing with WCF, truly a pain in the ass to only get it ready.
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.

puts = mapM_ putStrLn

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

>isis ambiguous
Is Haskell a terrorist language?

My dear user you have discovered a bug! Now you can say to contributed to ghc

I assume this is MonomorphismRestriction

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?

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

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.

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

I mean why it doesn't infer the type to be
Foldable t => t String -> IO ()

Oh, you're right, it's the MR. Adding the right pragma makes the compiler accept it.

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.

Fuck off Guido

wut about sockets

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

I primarily use c languages. python I just use to interactively talk to devices for the sake of reverse engineering their usb/hid protocols.

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?

>enlightened
>by a language for 3 year olds

The name `Python` comes from Monty Python, not the snake...

lets see you bind to an IP in C

This thread was doing so good with only hating on Java...

Ok? A python is still a snek

Yep. spam, eggs instead of foo, bar

>tfw recruiters don't like python

>tfw someone says some retarded shit

Are we being fucking raided by /vg/ or something?
What's with all these snake fags?

Dunno.

time to learn c#!

You fell for the meme

Why would people who use python be in /vg/?

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"

I am using it for its WPF lib

I am not fond of C++ or C so C# was a good compromise I think

amateur game dev general

If you are developing games in python you are a fucking retard.

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?

What possible reason could you have for learning haskell. Python would be 1000 times better for whatever you need.

I'm not sure what you are asking? Is your question: Why does function operating on monads need to be monadic?

if you are developing _ in python you are a fucking retard

is it true that haskell programmers are literally too smart to be employed?

Yes let user learn nothing new especially different paradigm. What benefit would he have from learning something different i wonder?

>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

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

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

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

That's what fmap () does
There are some examples It lets you apply a function within the applicative

It's related to the concept of a monoidal category


Python is trash, don't fool yourself

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.

What benefits? Please enlighten me.

You havent actually answered his question.
Why do you need to wrap +1 in Pure?

Python can do anything haskell can do except better buddy.

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.

pure x
is equivalent to
x


This is some quality bait

Can someone explain to me what lambdas are? Im afraid im an idiot.

neat, thanks. Still not exactly sure as to why

A cute name for anonymous functions.

>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.
name something you can do in haskell that you can't do in python.

Function literal

pure x vs x is a style choice, but itself is not the same as

there are examples of using here can provide sequencing too, and gives rise to *>
monadic >> is generally the same as applicative *>

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.

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

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

>HERP DERP FORCED STYLE
>HERP DERP WHITESPACE MATTERS
>HERP DERP FORCE EVERYONE TO WRITE BABBY TIER CODE
shit tier language

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 $$

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.

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.

b-but they don't

weird request, but could someone pastebin their Python.sublime-package file for sublime 3? Mine is corrupted

>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
I would think learning the matplotlib module is would require a different way of thinking then learning the socket module.
Don't make mistakes stupid.

>Nice syntax, not poorly thought out sugar
kek, python syntax is definitely bad but that doesn't make haskell syntax good fampai

I don't. The compiler doesn't let me.

>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

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 user, you're trying to sell this language to me, remember?

>opinion
__init__ and others for a start

>useless
Not at all.


Do you use Haskell?

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

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,

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

>My biggest gripe with python is its type system and performance

>python's type system
>python's performance

Don't worry user, NEITHER of those actually exist!
So you've got no problems with Python!

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.

>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

>jew = [[[]]]

same can be said for perl...

>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

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 thisis not me

ok? What does that have to do with anything?

i thought solving problems was what programming is about...

>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

>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

I thought programming was to achieve a goal, and to achieve that goal you have to solve problems.

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.

One person has been saying that

There are a lot of benefits to Haskell, e.g. the ones I listed here >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.

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

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.

Can I have one example, because I can give you a bunch of them for python?

>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?

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.

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

>why is that
It's a library feature.

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?

I would agree with that. I personally like haskell but i have never and probably wont use it in a real project

youtu.be/FGQAP0GxlW8?t=24m12s
Seek to 24:12 and listen to the anecdote.

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.

github.com/mccutchen/funcgeo
has the same thing in python haskell and a lisp

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


Haskell is an extremely nice general purpose programming language. If you really don't mind dynamic typing, I'm sure Python's fine.

did it fggts

youtube.com/watch?v=73O7tATQ8og

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

python is a handy tool only for projects that don't require performance
for example web-based projects

wow this is actually pretty good

nicely done

>for (int a = 1; 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.

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.

You should try haskell, it apparently boosts brain power.

>>use a class constant that makes it possible to change the number of steps

why didn't you just do 1 println anyway

He tried to be cool but ended up looking stupid

>class constant
His doesn't either.

>Java
I don't think he was trying to be cool

Is it worth it learn Assembly?

Well obviously from reading this thread you should never learn anything new that isnt immediately useful and doesnt bring $$. So no...

But user, 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.

Only good for debugging, reverse engineering, writing an OS or a compiler
If you're not doing any of those, I'd say no
Jesus, what are you so salty about

Depends on what you're doing. Good for embedded.

Lol salty bitch
Assembly is a great USEFUL language, unlike some.. *cough haskell cough*. If you learn assembly you can literally do anything.

>unlike some.. *cough haskell cough*.
*coughs behind you*
heh, nice try... kid

I don't get it.

*anything on silicon that supports the opcodes you learned
But yeah, asm is pretty damned nice.

haha are you mad about my haskell comment? That was just banter, relax

lurk more then eh

らきすた my nigga これのアニメがバッチグね。

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

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

You need spaces.

Wow they're literally gaging on their favorite code's cock

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

its public static main but oh well.
You should just go over to /sci and solve some homeworks thats what i do when bored...

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])))

thats worthy of perl!

cute

Impressive.

>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

This fucking song is stuck in my head

what book to learn c, then c++?

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

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.

>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)

oh, I see

/dpt/-chan, daisuki~

C primer plus then accelerated c++

No.

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

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

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.

Yes

Python is not really popular for game development.

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

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

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

The surrounding ( ) is a reference to Lisp

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

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

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

Ascii banner.

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

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

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

Thank you for using an anime image.

(You)

If you're going to do this you have to respond to every post.

why?

I wanted to be the first to reply to you senpai

>C primer plus
is there much difference between version 5 and 6? Found a cheap copy of 5

just torrent it and see for yourself. Than support by buying if you like

only have read the 6th which covers c11

oh k, pretty sure 5 covers 99

i might as well yeah

jew = []
...
jew.append...

Kek

Let's say I want to download this image

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

nvm solved

pm me for the fix

use binary mode.

What font?

>mfw learning bash and i thought i found bug on Cred Forums/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

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.

huh

well I finished my image scraper anyways

it's for a different chan but rather simple

pastebin.com/by6dEgTz

These things never require much thought

Bash syntax is gross. Don't use it for large scripts if you can avoid it.

f=open('boards\\'+name+'\\'+thread_name+'\\'+image_name,'wb')

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

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?

Binary translation is something used by many emulators to reach decent performances.

en.wikipedia.org/wiki/Binary_translation

Are there any resources for implementing binary translators?
I want to eventually do it for my VM.

Virtual Machines: Versatile Platforms for Systems and Processes

Ah, I already have that book, thanks.

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.

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

Anything involving strings.

Getting command line arguments.

i was thinking maybe a code snippet or something

I just want to read and understand a program that uses pointers

linked list

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.

Fucking look it up

Practically every non-trivial C program will make extensive use of pointers,
Do what says. Linked lists are a pretty good example of using pointers for dynamic data structures,

>Anything involving trees
no.

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

Implement a Binary Search Tree or an Abstract Syntax Tree without pointers. I dare you.

No. Copying is the first thing you have to learn if you want to become a good programmer..

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.

what language?

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.

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]);
}

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

Hachell ofc

Can someone tell me whether my linkedlist is good
pastebin.com/xVD0qrk0

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.

I looked it up. I feel dirty.

yes but then it's no more optimized for memory consumption

>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;

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.

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.

new thread when ? :3

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.

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.

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.

whenever

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 ?

धन्यवाद्

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?

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

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

You're not going to come up with mergesort on your first try though.

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.

gameprogrammingpatterns.com/contents.html

I'm not entirely sure what you don't understand about that function user. 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()

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.

I'll read it, thanks.

I'm working on learning Swift to make iphone apps.

Anyone have ideas for practicing at this?

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.

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
int main()
{
printf ("hello World\n");
return (0);
}

Problem is not with the code, ideone.com/VY0KsV

post the error message you are receiving.

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.

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.

Just use the website instead of shitting up the thread:
better-dpt-roll.github.io/

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.

Post the command you are using to compile and the error message you are receiving, and as 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.

Did you compile your code?
Did the compiler run without errors?
Also what compiler did you use?

New thread, when?

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.

When the thread hits bump limit in about 10 posts.

Feel free to spitball C# questions, I'll be lurking.

when this one reaches page 8 or 9, now fuck off.

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.

I'll take care, thanks. I am doing right using the terminal for these things? should I install an emulator or something?

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$

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.

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.

I'll redo all the steps and take notes/screenshots.
thanks for the answer, I was expecting to be insulted.

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

If you want to make your life learning c a little easier, try tutorialspoint.com/compile_c_online.php
But "learning" C without learning how to use a compiler is stupid.

For now you could try a site like ideone.com as mentioned in , 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.

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.

New thread when?

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.

...

Menlo Regular 13pt

Fuck em