[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
NO SWATISKA - /dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 27
Old: >>54874365
>>
1st for python
>>
>>54878963
Second for Python.
>>
>>54879008
>>54878963
why do we hate python again?
>>
>>54879014
>barely typed
>poor scoping system
>not a true indentation language
>default 4 spaces indentation
>>
>>54879014
Only fools hate Python.
>>
>>54879024
why hate 4 spaces?
>>
let fold_range start length a f =
let rec loop a i = function
| 0 -> a
| k -> loop (f a i) (succ i) (pred k) in
loop a start length
;;

let iter_range start length f =
fold_range start length () (fun () x -> f x)
;;

let fizz_buzz () =
iter_range
1 100
(fun i ->
let s =
match i mod 5, i mod 3 with
| 0, 0 -> "fizzbuzz"
| 0, _ -> "buzz"
| _, 0 -> "fizz"
| _, _ -> string_of_int i in
print_endline s)
;;

let () = fizz_buzz ();;


>>54879043
Because there is no good coder who doesn't use 2 spaces indentation.
>>
>>54879024
>barely typed
feature not bug, meant to be high level
>poor scoping system
blatantly wrong, scoping is uniform and intuitive
>not true indentation language
example needed
>4 space indentation
can be changed as long as consistent, how is being better readable in shell text editors a bad thing? what stone age editor are you using that doesn't support space indents?
>>
>>54879055
Shittiest reason I've ever heard. What do you even code?
>>
>>54879099
>example needed
How can I write a = 1 + 2 on two lines without parentheses? IN a true indent language it should looks like:
a =
1 + 2

but in python I failed to find the way to do that without parentheses.
>>
>>54879014
> no type hinting
> no real threading (CPython)
> no sane scoping rules
Even fucking PHP has all of those.
>>
>>54879099
>feature not bug,

- Excuse me sir. There are feces in my food?
- It's not an error sir, it's a feature...
>>
is there an equivelant of:
_popen("where python");
that doesnt open a dos window, and also isnt the clusterfuck that is CreateProcess?
>>
File: ProgPrinciples.jpg (41 KB, 408x500) Image search: [Google]
ProgPrinciples.jpg
41 KB, 408x500
So what is it with this book? Everything was ok until chapter 6 when the guy starts talking about tokens and making a calculator and then grammar and it just doesnt make much sense or maybe I just dont understand shit.

I just want to learn to program dude.
>>
>>54880505
C++ is one of the hardest programming languages to learn, java is like a simplified C++, i would recommend starting with java before moving on to C++

https://docs.oracle.com/javase/tutorial/
>>
File: Untitled2840.png (70 KB, 1920x994) Image search: [Google]
Untitled2840.png
70 KB, 1920x994
Working on displaying zones
>>
>>54879099
>blatantly wrong, scoping is uniform and intuitive
>global, nonlocal
Or the sane thing to do is declare every new variable so you don't have that awful mess or typing errors resulting in programming errors, sometimes far away from the typo. It's fucking retarded.
>>
>>54880958
How's learning C++ after having a somewhat decent foundation in C
>>
>>54880505
I attended TAMU when Stroustrup was there.

The reason for that is that he wanted to show you how to build something more complex than your average retard application. In addition to this, he wanted to show you the potential of grammars so when you're a sophomore, junior, and senior you can always be like hey I know that shit.

That book is a weird as fuck gem.
>>
>>54881120
You're developing that admin panel?
>>
>>54881204
Yep. A management front-end for LDAP, DNS, RADIUS and DHCP, mainly built around the IP address management functions.
I'm finishing the "manual" editing forms before I start on the integrated editing from the IPAM.
It will be a sort of alternative to Active Directory.
>>
>>54879055
Linus uses 8, is he a bad programmer now?
>>
>>54881135
i don't think it would be too bad but keep in mind that idiomatic C++ is fairly different to C so try not to stick to just a C-like subset of C++
>>
>>54881465
he's only really good for his knowledge about linux
>>
>>54881465
>sizeof() really is a function
>>
>>54881465

>Linus

who?
>>
Declarative and Imperative programming. What do these mean? What's the difference?
>>
>>54881938
en.wikipedia.org
>>
>>54881938
Buzzwords. The two types of programming are functional and non-functional.
>>
>>54881889
The tech tips dude
>>
>>54881889
xD
>>
>>54881239
Nice. Plan on ever releasing it to the public?
>>
>>54881980
>>54881981

Oh so nobody relevant right?
>>
>>54881959
Functional:
>Designed to be practical and useful, rather than attractive
>Working or operating
>>
>>54882159
it's disgusting that they hijacked this word

it's based around functions
>>
What's a good project to work on to learn about parallel processing and working with GPUs?
>>
>>54878937
fork(turn(1));
fork(turn(2));
forward(3);
turn(1);
forward(2);

I challenge you guys to make that compile to a "swatiska".
>>
Crystal looks like a cool memelang, what do you guys think? One thing Ruby got right was the syntax, so I think it's a great design choice to copy it.
>>
>>54882721
it's made by an autist for starters.
>>
>>54882746
kys
>>
If I open a file but use a pointer as the variable can I jump around the file without loading the entire file to ram. Like I could work with 10gb files and such.
So something like
FILE *file;
file=fopen("10gigs","rb");
int x[10];
for (i=0, i<10, i++)
x[i]=file+i;

Or something similar to that since I doubt thats actually how it works.
>>
>>54882839

You can move around through a stream with fseek.
>>
cracking android apps and giving em for free in app store just to shit on hipster and poo2loo programmers lol
>>
>>54882721
memelang/10
>>
>>54880958
The Oracle tutorial isn't the best. I got a lot more out of the book that comes up by searching "java 10th edition pdf". It's an extremely beginner oriented textbook, but you can really challenge yourself with the exercises.
>>
>>54881239
Looks cool. Will it be free and open-source?
>>
>>54882921
I think he said earlier that it was for some internal thing, so most likely proprietary.
>>
>>54882956
Thanks, must have missed that post.
>>
What the fuck?
Why is this thread up?
Why didn't a mod delete it?
Do mods just roll dice these days?

>>54877214
>>
A test script I have used for my compiler:

(* This program should have no problem dealing with
(* Nested comments *)
(* (* By now *) *)
*)

program TestAll ;
function AddTwoSubDefaultThree(
value x : integer;
value y : integer <-- 3
) returns integer;
variable z : integer;
begin
z <-- 2;
return (x + z) - y;
end AddTwoSubDefaultThree ;

procedure SetToNine(variable x : integer) ;
begin
x <-- 9;
end SetToNine;

variable k : integer;
variable b : boolean;
begin
write("two: " ; AddTwoSubDefaultThree(3));
writeln();
write("three " ; AddTwoSubDefaultThree(3, 2));
writeln();

b <-- (2 < 5);
if (b) then
write("this should be printed");
writeln();
elsif (5 > 3) then
write("this, while true, should not be printed");
writeln();
else
write("this should definitely not be printed");
writeln();
end if;

k <-- 1;
repeat
write("this should be printed four times");
writeln();
k <-- k + 1;
until (k = 5);

SetToNine(k);
write("This should print 9: " ; k);
writeln();

write("Thank you, have a nice day!\n");
end TestAll .


Resulting output:

two: 2
three 3
this should be printed
this should be printed four times
this should be printed four times
this should be printed four times
this should be printed four times
This should print 9: 9
Thank you, have a nice day!
>>
File: 91i328.jpg (142 KB, 740x740) Image search: [Google]
91i328.jpg
142 KB, 740x740
>>54883154
>>
>>54883154

Oh wow, it's Ada/Pascal with weird assignments.
>>
>>54883221

Yep. And I have to compile that ugly son of a bitch.

All I have left is to handle arrays. I do not want to handle arrays.
>>
>>54882850
even a stream thats like 10gbs?
>>
>>54883463

Yes, any stream.

>>54883385

Good luck. I tried to implement vectors in SP4 and I just gave up.

Does your lang have compound data types?
>>
Can anyone help me out? Our professor assigned this before our final and didn't have time to post a lecture. Any chance anyone can help me out if I post the assignment?
>>
>>54878937
What language is the best for programming neural networks for trading stocks?
>>
>>54884199
literally any language

or just use a pre-existing neural network library
>>
What language is a good one to learn if I used to make games on the TI graphing calculators in High School?
>>
>>54882839
seekg and seekp are capable of random access if you know how much data to skip
very useful if you use a flattened 3d array or something
>>
>>54884220
ooh
>>
>>54883702

Nope, just integers, booleans, and arrays of integers or booleans. Although strangely enough, the arrays don't have to be zero indexed, they can have any custom range, which has to be checked at runtime. For some reason, my compiler gets weird behavior when the range starts with a negative number, and that weird behavior gets seen as early as when the type is constructed in the .y file. Like somehow the scanner is passing it a random number instead of a negative number. Except when I use negative numbers in ANY OTHER CONTEXT, they turn out fine.

Oh well, since it gets most of the basic shit for code generation done, it should still get an A or an A-, I'm thinking.
>>
File: The Art Of Trolling.png (85 KB, 1264x904) Image search: [Google]
The Art Of Trolling.png
85 KB, 1264x904
Old thread _still_ isn't dead

>>54885620
Reminder to add ADTs, pattern matching & overload style pattern matching (ala Hasklel)
>>
>>54885678

The language doesn't support that shit, and I'm not going to add features onto an already ugly as shit language. It'd be better to make my own.
>>
>>54885697
Do it faggot

Whatever happened to that guy writing pipes or whatever
>>
>>54884177
Sure we are all here to help you Anon.
You're welcome.
>>
>>54884177
Just tell us the assignment and we'll do it for free
>>
File: friendly advice.png (100 KB, 715x611) Image search: [Google]
friendly advice.png
100 KB, 715x611
>>54885740
(delivery not included)
>>
>>54878937
bump
>>
>>54882057
>>54882921
I will release it when the basic functionality is finished.
Probably free (MIT license), with paid support or hosting.
>>
am i l33th4x0r yet?

import time
list = ['..++++++++',
'+..+++++++',
'++..++++++',
'+++..+++++',
'++++..++++',
'+++++..+++',
'++++++..++',
'+++++++..+',
'++++++++..',]
i = 0
x = 0
while i != 1:
print(list[x])
x += 1
time.sleep(0.5)
if x == 9:
while (x > 0):
x -= 1
print(list[x])
time.sleep(0.5)
>>
>>54878937
>C++
>imperative, object oriented

>they don't know that
C++ is procedural (nearly backwards-compatible with C)
C++ is functional (first class functions, lambdas)
C++ is declarative (templates form a turing-complete, declarative-logic language INSIDE OF normal C++)
>>
>>54886549
>using a preexisting list
>actually hardcoding that list
>>
File: bitch.jpg (23 KB, 588x271) Image search: [Google]
bitch.jpg
23 KB, 588x271
>>54886590
i do what i want with my time.
>>
>>54886626
you want to write shit code?
>>
>>54886645
im new senpai plz. just bored trying to practice.
>>
>>54886655
import time
x,dx = 0,1
while True:
if x + dx > 8 or x + dx < 0:
dx = -dx
x += dx
print("+" * x + ".." + "+" * (8 - x))
time.sleep(0.2)
>>
>>54886589
it's arguably primarily OOP, it's one of the most OOP-compatible mainstream languages and it's the language that the super-OOP java was based on
>>
>>54886688
True, but none of my C++ code is OOP.
>>
>>54886661
that is the coolest thing ever
>>
>>54886661
woa. seems i need more practice. how do i learn to write more efficient code with other than just experience and time?
>>
>>54886549

Your script is cool. :)

Feedback for you:
- your outer loop runs forever, and this looks intentional. If you want an infinite loop, a very readable way to say this is either "while true" or "while 1" if your language doesn't have booleans
- Try to avoid overly nesting your algorithm. You can do this one in one while loop as follows

forward = true
x = 0
while true:
time.sleep(0.5)
print(list[x])
if forward and x < 9:
x++
if not forward and x > 0:
x--
if forward and x == 9:
forward = false
if not forward and x == 0:
forward = true


(I'm not sure if this script exactly meets the spec of yours, but I'm just doing this to demonstrate the idea of what I mean)

Overall you did really well. Try making a program that can interact with a GUI next and draw ascii shapes :)
>>
>>54886706
this has obfuscated the code so much i don't even know if it's verbose or not at this point
>>
>>54886702
Math. Yep. Fuck the haters.
You need to be able to realize simple math (and mathematical logic) to be able to write more efficient code, sometimes.
>>
>>54886589
>templates form a turing-complete, declarative-logic language INSIDE OF normal C++)
>Turing complete
That's not a good thing.
>>
#include<stdio.h>
#define decode(s,t,u,m,p,e,d)m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
printf("Hellow World");
}

WTF is happening here?
This is some magic code that writes hellow world without main my which curryfag friends think that the interviewer will ask
>>
>>54886718
No, but I fucking love it.
I wrote compile time linked list comprehension using C++ types, but I think I deleted the source code.
>>
>>54886720
>This is some magic code that writes hellow world without main my which curryfag friends think that the interviewer will ask
It's not magic, just GNU macro magic.

m##s##u##t


This macro expands to "main"

m is m
##s expands to a (first argument)
##u expands to i (third argument)
##t expands to n (second argument)
>>
>>54886718
It is

#include <cstdio>

template<bool> struct Value;

template< int n, typename = Value<true> >
struct fizzbuzz
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
printf("%d\n", n);
}
};

template <int n>
struct fizzbuzz< n, Value<(n == 0)> >
{
fizzbuzz() { }
};

template <int n>
struct fizzbuzz< n, Value<(n > 0 && n % 15 == 0)> >
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
puts("fizzbuzz");
}
};

template <int n>
struct fizzbuzz< n, Value<(n > 0 && n % 3 == 0 && n % 5 != 0)> >
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
puts("fizz");
}
};

template <int n>
struct fizzbuzz< n, Value<(n > 0 && n % 5 == 0 && n % 3 != 0)> >
{
fizzbuzz()
{
fizzbuzz<n-1> fb;
puts("buzz");
}
};

int main()
{
fizzbuzz<100> fb;
return 0;
}
>>
>>54886720
## is the preprocessor token pasting operator. It combines two token together, so "a ## b" will combine to "ab".
Now if you expand the macros by hand:
begin ->
decode(a,n,i,m,a,t,e) ->
m##a##i##n ->
main


>>54886735
>GNU
Token pasting is standard C.
>>
File: runtime get out.png (22 KB, 1161x407) Image search: [Google]
runtime get out.png
22 KB, 1161x407
>>54886718
>>54886728
>they actually run their code
>>
>>54886746
Good job on making your language undecidable to parse.
>>
>>54886748
>>54886746
C++ is interpreted now, bois
>>
>>54886706
your version has an excessive number of if statements and comparisons

imo it would be better to have a while true outer loop and then two separate inner loops
>>
>>54886706
made this today
http://pastebin.com/gQAenZHi
hardest part was the calculation part.
>>
>>54886760
>your language

>>54886770
There is no point in interpreting templates desu. Well, other than convenience.

The biggest benefit of C++ templates is that they are evaluated at compile time, leaving you with ultra-light and very fast generics.
>>
>>54886791
>The biggest benefit of C++ templates is that they are evaluated at compile time
Yeah but it's fun to pretend that C++ is interpreted by writing all of your code in templates, so that "running your program" means "running the compiler on your code", making the compiler the interpreter and the compiled output (or the error message, in the case of a clever anon), the result of the program.

On a serious note, the real power from C++ templates comes from not only template instantiation, but:
>overloaded functions
>operator overloading
>implicit constructors
>>
>>54886791
>>your language
Your meme arrows don't make C++ any less undecidable to parse.
>>
>>54886818
I disagree actually. I agree that those three are really nice and nifty, but templates (and by extension) the STL and RAII would make C++ worth to use over C alone, IMHO.

But of course, those things are really nice to work with, so I would definitively want those too.
>>
>>54886845
>write invalid code
>complain it's inparsable
>>
>>54886845
>undecidable to parse
Your broken English doesn't make sense to anyone. WTF are you even trying to say? That it is somehow hard to parse?
>>
File: 1421102427031.png (1 MB, 1422x815) Image search: [Google]
1421102427031.png
1 MB, 1422x815
>>54886870
>>>>>
>>
>>54886870
"Undecidable" is a computer science term, you fuckwit.

>>54886864
http://blog.reverberate.org/2013/08/parsing-c-is-literally-undecidable.html
struct SomeType {};

template <...> struct TuringMachine {
// Insert implementation of a Turing machine here, which we know
// is possible from previous proofs.
};

template <typename T> struct S {
static int name;
};

template<> struct S<SomeType> {
typedef int name;
};

int x;
int main() {
S<TuringMachine<...>::output>::name * x;
}

How is that invalid?
>>
>>54886549
import time
list = ['.......',
'*..****',
'*..*...',
'*******',
'...*..*',
'****..*',
'.......',]
x = 0
while True:
print(list[x])
x += 1
time.sleep(0.08)
if x == 7:
while (x > 0):
x -= 1
print(list[x])
time.sleep(0.05)

fuck you OP
>>
>>54886885
>computer science
Fuck off and dick around with your lambda calculus.

No one in the real world cares.
>>
>>54886897
You seriously can't be this retarded.
>>
>>54886885
>that's what you meant by undecidable
Holy shit that's a dumb fucking complaint

The outcome of C programs is literally undecidable
>>
>>54886909
>The outcome of C programs is literally undecidable
And that's completely unrelated.
Also, you're a fucking retard as well.
>>
File: maximum-damage-control.jpg (138 KB, 650x650) Image search: [Google]
maximum-damage-control.jpg
138 KB, 650x650
>>54886905
>"oh shit i'm losing an argument on the internet"
>"better call him retarded"
>>
>>54886885
>wahhh this lang is turing complete and i don't know what it means
>>
>>54886923
No it's not. Look at what you just fucking posted you dumbass. Templates can be turing machines, therefore instantiating C++ templates is undecidable. What a dumb fucking comment.
>>
>>54886924
There is no point even acknowleding retardation of your level, let alone argue about it.
Consider yourself lucky that I gave you any (You)s at all.
>>
>>54886941
>Templates can be turing machines, therefore instantiating C++ templates is undecidable.
This
>>
>>54886941
>programs can be turing machines, therefore instantiating C++ programs is undecidable
this is how ridiculous you sound
>>
>>54886962
Yeah, so maybe now you understand how fucking American you sound when you make this out to be a fucking problem
>>
>>54886952
>gave you any (You)s
I would prefer that you'd stop posting a long time ago.

See >>54886941
Your argument is basically "turing complete templates are bad because they are undecidable"

Yeah, no fucking shit they are undecidable. So what? How does it make it bad? Are all Turing complete programs bad?
>>
>>54886886
i dont even know what that pattern is
>>
>>54886983
It's the windmill of friendship
>>
File: what.png (6 KB, 641x270) Image search: [Google]
what.png
6 KB, 641x270
>>54886997
what
>>
>>54887005
alright try this
import time
list = [' ',
' = ==== ',
' = = ',
' ======= ',
' = = ',
' ==== = ',
' ',]
x = 0
while True:
print(list[x])
x += 1
time.sleep(0.08)
if x == 7:
while (x > 0):
x -= 1
print(list[x])
time.sleep(0.05)
>>
>>54886626
>>54887005
Fun with math
from time import sleep
from copy import copy
from math import sin, cos
W = 32
H = 30
grid = [False] * (W * H)
def pixel (x, y, p):
if 0 <= x < W and 0 <= y < H:
grid[x + y * W] = p
def clear ():
global grid
grid = [False] * (W * H)
def present ():
q = ""
for i in range(H):
s = " ".join(map(lambda x:".#"[x], grid[i * W:i * W + W]))
q += s + "\n"
print(q)
def line (x1, y1, x2, y2, p=True):
dx = x2 - x1
dy = y2 - y1
if abs(dx) > abs(dy):
if dx < 0:
return line(x2, y2, x1, y1)
for i in range(dx + 1):
x = x1 + i
y = y1 + i * dy // dx
pixel(x, y, p)
else:
if dy < 0:
return line(x2, y2, x1, y1)
for i in range(dy + 1):
x = x1 + i * dx // dy
y = y1 + i
pixel(x, y, p)
theta = 0
radius = 13
while True:
x,y = W // 2, H // 2
dx = int(sin(theta) * radius)
dy = int(cos(theta) * radius)
clear()
line(x + dx, y + dy, x - dy, y + dx)
line(x - dx, y - dy, x - dy, y + dx)
line(x - dx, y - dy, x + dy, y - dx)
line(x + dx, y + dy, x + dy, y - dx)
present()
theta += 0.1
sleep(0.1)
>>
>>54887005
the asterisks form swastikas
>>
>>54886979
>So what? How does it make it bad?
It makes the language ridicously hard to implement, and makes compilation times ridicously slow.
>>
File: turtling.png (126 KB, 795x717) Image search: [Google]
turtling.png
126 KB, 795x717
>>54887005
Will you be my
. . . . D . . . . . .
. . . N . . . . . . .
. . E . . . . . E . .
. . . I . . . I . N .
. . . . R . R . . . D
. . . . . F . . . . .
D . . . R . R . . . .
. N . I . . . I . . .
. . E . . . . . E . .
. . . . . . . N . . .
. . . . . . D . . . .
>>
>>54887008
Holyfuck how did you even
>>
>>54887042
yes
>>
>>54887008
lol this is mad.
>>
>>54887008
bretty gud my friend
now make a 3D cube
>>
>>54887013
>It makes the language ridicously hard to implement,
Well, the prevalence of C++ compilers prove this wrong. But yeah, C++ is not C. It's not aimed at being the first language ported to a new architecture.

>and makes compilation times ridicously slow.
Precompiled headers, mang. They are a must, even in C.
>>
>>54887097
how would you even portray that. unless python has a 3d rendering thing im unaware of
>>
>>54887108
smart thinking my thank
you just have to thnk smart
>>
>>54887108

your screen probably isn't 3d
it's probably 2d
>>
>>54887108
You use maths to project a 3D cube on a 2D surface and display it, it's hard but possible.
That's basically what 3D engines are doing except it's pixel not characters
>>
File: 1463697124412.png (691 KB, 644x646) Image search: [Google]
1463697124412.png
691 KB, 644x646
>>54887008
>mfw this is the highest level of graphical performance Python is capable of
>>
File: 37.png (92 KB, 969x1145) Image search: [Google]
37.png
92 KB, 969x1145
>>54887108
>>
>>54887097
That was my original goal but I thought I'd be able to make the 2d one easier.
Working on 3D now.
>>
>>54887157
Good luck m8
>>
>>54887157
what do I have to learn to make things like this 2d
>>
>>54887185
If you want to render 3D stuff on 2D surface
https://en.wikipedia.org/wiki/3D_projection

For 2D stuff it's just some simple maths, it's really easy
>>
>>54887185
trigonometry
>>
File: 1461932176436.png (643 KB, 678x653) Image search: [Google]
1461932176436.png
643 KB, 678x653
>>54887185
>use 4chan
>don't know 2d theory
>>
>>54887202
I never had math in school although I really wanted to learn it
so as I think it is is that math got a lot of parts what it can do from tables to algoritms
which part of math is this?

>>54887237
blame my school for not teaching me anything besides my own language and that I will be trash when growing up
>>
>Unironically using a programming language that isn't imperative.
>>
>>54887242
It's just some cos and sin, basic trigonometry for 2D stuff
For 3D you would need matrix to make things easier
>>
>>54887261
3dpd anyway
>>
>>54887261
a matrix is still just trigonometry, scale (multiplication) and translation (addition) baked into one big thing
>>
Intro to 2D Graphics

https://www.youtube.com/watch?v=z23Gzp0RTOg&t=19s

Required Listening
>>
>>54887279
Yeah sure but you need to learn how to do operation on matrix, a little harder than cos and sin multiplications
>>
>>54887281
my sides
>>
>>54887281
>wayfu
>>
>>54887314
There's nothing wrong with waffles
>>
>>54887281
>It ties back to meta physics
My sides.
>>
>>54887108
>>54887157
use xyz coordinates, rotate in the xy plane like for 2d, and rotate in xz and yz planes as well, then take the resulting xy coordinates and there you have orthographic projection
>>
>>54887160
>>54887097
>>54887340
Lots of trial and error later...
from time import sleep
from copy import copy
from math import sin, cos

W = 32
H = 30
grid = [0] * (W * H)
ts = 0

def pixel (x, y, p):
if 0 <= x < W and 0 <= y < H:
i = x + y * W
grid[i] = max(grid[i], p)
def clear ():
global grid
grid = [0] * (W * H)
def present ():
global ts
ts += 1
q = str(ts) + "\n"
for i in range(H):
q += " ".join(map(lambda x:".#o"[x], grid[i * W:i * W + W]))
q += "\n"
print(q)
def line (x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
pixel(x1,y1,2)
pixel(x2,y2,2)
if abs(dx) > abs(dy):
if dx < 0:
#x1,dx,y1,y2 = x2,-dx,y2,y1
return line(x2,y2,x1,y1)
for i in range(dx + 1):
x = x1 + i
y = y1 + i * dy // dx
pixel(x, y, 1)
else:
if dy < 0:
#y1,dy,x1,x2 = y2,-dy,x2,x1
return line(x2,y2,x1,y1)
for i in range(dy + 1):
x = x1 + i * dx // dy
y = y1 + i
pixel(x, y, 1)
def project3d (pt):
x,y,z = pt
w = 20 / z
x2 = x * w + W / 2
y2 = y * w + H / 2
return int(x2), int(y2)
def poly (n, pts):
for i in range(n):
x1,y1 = pts[i]
x2,y2 = pts[(i+1)%n]
line(x1, y1, x2, y2)
x = 0
z = 13
y = 4
w = 7
theta = 0
while True:
dx,dz = cos(theta) * w, sin(theta) * w
corners2d = [(x+dx,z+dz),(x-dz,z+dx),(x-dx,z-dz),(x+dz,z-dx)]
top,bot = [],[]
for x0,z0 in corners2d:
top.append((x0,-y,z0))
bot.append((x0,y,z0))
clear()
poly(4, list(map(project3d,bot)))
poly(4, list(map(project3d,top)))
for (a,b) in zip(top,bot):
x1,y1 = project3d(a)
x2,y2 = project3d(b)
line(x1,y1,x2,y2)
present()
theta += .1
sleep(.1)


>>54887284
>>54887279
>>54887261
Fuck yall I didn't need to use any matrix math.
>>
It looks a lot like even though they are outbreeding us, we are outmeme-ing them, and that gives us a decisive advantage.

But we should also be kind of scared of this process. Memes optimize for making people want to accept them and pass them on – so like capitalism and democracy, they’re optimizing for a proxy of making us happy, but that proxy can easily get uncoupled from the original goal.
>>
Chain letters, urban legends, propaganda, haskell and viral marketing are all examples of memes that don’t satisfy our explicit values (true and useful) but are sufficiently memetically virulent that they spread anyway.
>>
File: 1441589694585.jpg (76 KB, 500x464) Image search: [Google]
1441589694585.jpg
76 KB, 500x464
>>54887474
>>
File: 1463537989573.jpg (474 KB, 1000x1540) Image search: [Google]
1463537989573.jpg
474 KB, 1000x1540
>>54887412
Looks like everyone is asleep. Goodnight.
>>
File: moloch-tshirt.png (49 KB, 330x288) Image search: [Google]
moloch-tshirt.png
49 KB, 330x288
>>54887490
>>
>>54887599
lol its noon.
Some anons are at work!

anyway, nice cube, good job, I'm not into python myself and no time for discussing math thou so I can't comment much.
>>
>>54886780

absolutely, however consider this

quite often, your problem in code is NOT "how do I reduce the number of instructions" or "How do I make the file size smaller" it's "how do I change this code later when the spec changes?"

If you wanted to change the hardcoded list to a function parameter, it's easy. If instead of random strings you had database entries, that's easy too.
>>
>>54887102
>a must, even in C
not at all
>>
>>54887698
It is. The difference between precompiled headers and not when compiling the Linux kernel is literally 10-15 minutes.
>>
>>54887713
Templates are poor man's metaprogramming. Lisp macros are more expressive, just as powerful and trivially implementable.
>>
>>54879014
>9,001x slower than anything else

And why the fuck would I start something in a language without a true compiler that can output real machine code any way?
>>
>>54886790
>http://pastebin.com/gQAenZHi

Nice and elegant my man!

For larger projects you may want to consider file maintenance strategies, such as 1 class per file, and separating your logic from your ui TKinter code from your main script down the bottom there.

Overall you should feel proud, nice effort.
>>
>>54887751
PyPy
Numba
Cython

>why learn dynamic language
To save your valuable time, dum-dum
>>
>>54882129
LINUS FUCKING TORVALDS YOU FUCKING PAJEET CURRYNIGGER
>>
>>54887794
Calm down son, you're eating the memes too hard
>>
Thus we arrive at Neoreaction and the Dark Enlightenment, wherein Enlightenment science and ambition combine with Reactionary knowledge and self-identity towards the project of civilization. The project of civilization being for man to graduate from the metaphorical savage, subject to the law of the jungle, to the civilized gardener who, while theoretically still subject to the law of the jungle, is so dominant as to limit the usefulness of that model.
>>
>>54887785

also consider how brackets would change your addfunction method. Now you can't just parse the equation right to left you have to look for what the user wants done first.
>>
>>54887817
Is that you, Urbit-kun?
>>
https://github.com/cgyarvin/urbit/blob/master/doc/book/0-intro.markdown
>>
>>54887874
I want to learn Nock and Noon, they are so sexy *__*
>>
File: 1459565014310.gif (349 KB, 350x233) Image search: [Google]
1459565014310.gif
349 KB, 350x233
>>54887954
It's Hoon, you dumbass
>>
did 4chan die again?
>>
>>54887746
...and slow as hell because, you know, it requires a lisp machine.
>>
>>54887794
Linus Torvalds has Indian grandparents.
>>
Hi. I made an esoteric language and called it 9+QH.
The code is divided in 4 types of blocks (9, +, Q and H), each with its own set of instructions. You can have multiple blocks of the same type in a program tho
ugh.
Every program written in 9+QH is also a valid HQ9+ program. https://esolangs.org/wiki/HQ9+

9 - data operations block
It operates on a single array of chars (ASCII) and maintains two pointers: current cell pointer and last cell pointer. The state of the array as well as the po
inters are kept between the blocks and also accessible in other blocks.
The operations in this block are:
+ - increment the value of current cell
Q - negate the value of current cell bitwise
QQ - read a char from standard input and write it in current cell
H - if current cell pointer equals last cell pointer then:
- if current cell equals 0, reset current cell pointer to 0, otherwise increment last cell pointer
- otherwise increment current cell pointer
9 - exit data operations block

+ - code block
The operations in this block are:
H - label/GOTO
You can declare 3 labels in a block: 9, + and Q. First time a label is called is its declaration. Every next use is a GOTO instruction, jumping to the label.
Example:
- HQ - declare a label Q
- H9 - declare a label 9
- H9 - goto 9
- HQ - goto Q
- H9 - goto 9
HH - global label/GOTO. Same as above, except the labels may consist of more than one character and are H-terminated. Global labels are also accessible from ou
tside the block where they were defined.
Example:
- +HH+H+ - code block; declare a global label +
- 9+9 - data op block; increment current cell
- +HH+H+ - code block; goto +
Q - perform next operation only if current cell is non-zero
QQ - perform next operation only if current cell equals 0
9 - print the value of current cell on standard output (as a character)
+ - exit code block
>>
>>54889189
Q - algorithm block
Implements some of the behaviour of HQ9+ and some other useful features. The operations in this block are:
H - print "Hello, world!"
HH - print the lyrics of "99 Bottles of Beer" (note that it also prints "Hello world")
9 - sort the data kept in the array in non-decrementing order
+ - shuffle the data in the array
++ - shuffle the code too
Q - Print quine and exit algorithm block

H - exception block
This block aims for eliminating programmer's errors. A valid program should never enter this block (unless intended). There are no instruction at all, not even
an exit instruction and everything gets ignored. When an interpreter/compiler reaches an exception block, it is permanently changed into a HQ9+ interpreter/co
mpiler, including any future instalations of the interpreter/compiler on the machine.
>>
>>54888784
>I never used a Lisp language: the post
>>
>>54889216
which lisp has proper arrays and resizearrays? (not linked list basically)
>>
>>54889341
Common lisp, racket
>>
>>54889341
Virtually all of them
Emacs Lisp
Common Lisp
Scheme
Racket
Clojure
Very few lisp don't provide an array datatype, but AFAIK there is no Lisp where contiguous arrays are used INSTEAD OF singly linked lists, but apart from memes, what would be the point???
>>
>>54889189
>>54889204
This program prints "Hello!":
9++++++++9
+HH9H+
9H+++++++++HHQ+Q9
+QHH9H+
9H9
+9+
9+HH++++9
+HH+H+
9H+++++++HHQ+Q9
+QHH+H+
9H9
+9+
9+++++++9
+99+
9+++9
+9+
9H+++9
+HHQH+
9H+++++++++++HHHHQ+Q9
+QHHQH+
9H9
+9+
>>
>>54889189
>>54889204
Cat program:
+HH9H+
9QQ9
+9QHH9H+


Truth machine: https://esolangs.org/wiki/Truth-machine
9QQ9
+H99QH9+
>>
File: images.png (12 KB, 262x192) Image search: [Google]
images.png
12 KB, 262x192
I want to start learning c# and unity to make a voxel game similar to ace of spades.

What are some good c# books and unity tutorials?
>>
>>54887787
>numba
Thanks anon
>>
Suppose we are working with intensional Martin-Löf type theory. Does anyone have any idea if adding quotient types forces the system to be extensional, and if it does, is there some weakened version of quotient types? I know that there is one person here who knows about this stuff.
>>
>>54889854
>>>/vg/agdg
>>
Forgive my ignorance as I'm only a hobby programmer -- but is it common practice to make a git commit without testing compilation?

On a few different occasions I have cloned a repo and been unable to compile due to errors in the source. Once I was able to fix the issue myself, but not the other 2-3 times.
>>
>>54891916
Yes because you usually have stable branches/tags and the master branch (default) is usually used for development so thinks are to be expected to not work properly there
>>
>>54891916
Not all commits are created equal, I'd say. Especially in small projects, you can't expect master to be shippable at any given time, sorry.
>>
>>54891916
Even if the code in master happens to compile, you should not assume it is correct. It's very likely untested and almost certainly contains bugs and omissions. Stick to stable releases if you actually want to use the software. master is for contributors.
>>
what are some good uses of geometry shaders besides shadow volumes, grass/tree leaves, character fur/spikes?
>>
I've heard a lot about boost (C++). Well, I've heard of it a lot, not a lot about it.

What the hell is it? Why does anyone I consider a good programmer get this empty look whenever it's mentioned?
>>
>>54892188
Anything that shares the characteristics those have that make geometry shaders appropriate.
>>
>>54892792
Boost is a collection of C++ libraries.

Proponents point out that they're thoroughly tested, extensively peer-reviewed, widely supported, solve real-world problems, and conform well to C++ idioms and standards.

Objectors point out that many of them are obtuse, over-engineered, very slow (at run time), very slow to build (due to being mainly header-only and heavily templated), and result in worthless compiler error messages when things go wrong.

Both parties are completely correct. My own opinion is that if you're building something very performance sensitive (realtime video games), you probably don't want to use Boost. If you're building something less speed sensitive, like business logic- and you have to use C++ for some reason- it probably does make sense to use Boost.
>>
>>54892792
Boost is a bunch of libraries. Some Boost libraries end up in the STL, others don't.
>>
>>54887816
reeeee
>>
http://sijinjoseph.com/programmer-competency-matrix/

How competent are you, /dpt/?
>>
What is the language for my political views? Clearly,

Java is for democrats
C/C++ is for republicans
Rust is for sjw
Assembly is for communists
Haskell is for technocrats

what language can a warm-blooded Trump support use?
>>
>>54893291
>all these "know algorithm"/"know software environment"
Annoying.
I'm N on most but log(n) on a fair few.

I consider myself barely proficient though. I'm surprised there's no API design talk..
>>
>>54893305
Their own
>>
>>54893291
I'm a fucking god.
>>
>>54893305
>Assembly is for communists
Anarchists (an-com) rather. Not communists.
>Java is for democrats
Toddlers, unaffiliated.
>C/C++ republicans
That's a very narrow view //C-dev
>Rust
Dunno
>Haskell technocrats
Yeah.
>Trump
JS. Probably.
>products aim for exposure
>low quality products
>employees being replaced by H1B1 (not saying trump would actually stop that, but yeah)
>>
>>54893361
>I'm surprised there's no API design talk..
The list is made by an ugly Pajeet, what do you expect?
>>
>>54884391
Nigerian
>>
i want to make a simple bot for my friends twitch chat, I want to learn something new doing it.
lua, python, cpp are languages I want to learn in the near future, what language should I use?
>>
>>54893629
forgot about haskell just for the giggles, I already know the basics
>>
>>54893423
>an-com

Haha lmao
>>
>>54893662
https://www.youtube.com/watch?v=M-iccvkSDeo
>>
>>54893662
>anarchy
Haha lmao
>>
What do I need to learn to be prepared for K&R?
>>
>>54893828
How to read English.
>>
>>54893828
Javascript: The Good Parts
>>
>>54893828
Haskell
>>
>>54893629
python
>>
>>54893828
C
>>
>>54893828
If you read the prefece it says:
>"The book is not an introductory programming manual; it assumes some familiarity
with basic programming concepts like variables, assignment statements,
loops, and functions. Nonetheless, a novice programmer should be able to read
along and pick up the language, although access to a more knowledgeable colleague
will help."
So. Nothing really.
C is a very simple language. The book doesn't really teach you much honestly. It's just a good book because it's a book from the time where computers were regarded as real physical devices. Software was written with resources in mind.
>>
Reminder that the old thread still isn't dead
>>54877214
>>
File: cover.jpg (247 KB, 1125x1388) Image search: [Google]
cover.jpg
247 KB, 1125x1388
>>54893828
This to be jitsuwa senpaifam or possibly Code : The Hidden Language of Computers etc. by Charles Petzold if you're strapped for time.
>>
>>54878937

>dividing imperative languages into procedural and OO

Lets' face it, OO is just an added functionality, not a whole new paradigm.
>>
>>54893497
Ooga booga where all da desi women at
>>
>>54894149
No OOP is a thing.
It's about encapsulation and messages.
Only retards think it's about merging structs and virtual pointers.
>>
>>54894173
I see nothing paradigm shifting gained from encapsulation, and I simply don't understand what you mean by messages.

Maybe in java, where you are simply forced to make even the trivial stuff into it's own class, but it's more of a hassle than a paradigm in itself.
What I've said holds especially true for C++. It's just imperative with a great new functionality added.
>>
>>54894173
Encapsulation a shit
>>
>>54894149
Functional ⊂ Sequential ⊂ Object-oriented ⊂ Concurrent ⊂ Logic ⊂ Term-rewriting
>>
>>54894315
>>54894340
No OOP is dumb. I'm not arguing that it's useful in anyway. But OOP is a thing and encapsulation is core to the concept. It's dumb and doesn't really allow for optimal programs like functional programs would.

People do call their code OOP incorrectly though. Usually with less precision than people who do functional programming for instance. So it's becoming more of a meme than a serious thing.
>>
>>54894351
>logic programming is a subset of object-oriented programming

wat
>>
>>54894385
It goes the other way
Functional is a subset of sequential which is a subset of object oriented ...
>>
>>54894385
You read it backwards.
https://en.wikipedia.org/wiki/Subset
>>
>>54894376
I've just got up and I'm kinda cranky, so that's why I dissed oop completely.

With the introduction of classes and that encapsulation we are introduced to hierarchy planning and stuff like that. and if you really get into that kind of a mindset, especially with java that forces the user to make everything into a class then it does seem different enoguh from standard stuff like c.

But I still feel like it needs to be kept under strict control. Like it's unbelievably useful sometimes, for example I wrote a small example compiler with lex and yacc first using simple and the case switch functions grew to ridiculous sizes, and then with c++ where each class lnew how to compile itself.
>>
>>54894423
Though I should add I don't consider functional a subset of object oriented programming at all.
This is a dumb way of putting it. The overlap isn't complete in most of these cases. Intersection would be better.
>>54894471
There's way better of dealing with this. OOP really just hides your problems. Makes it seem better for some maybe.
>>
>>54894423
Functional isn't a subset of sequential
see Haskell
>>
File: 131241521.gif (779 KB, 500x281) Image search: [Google]
131241521.gif
779 KB, 500x281
>subset
>set theory
>not sub-category
triggered
>>
>>54894634
Set theory and category theory are two different things. For example, you can't have the set of all sets in set theory, but in category theory you can.
>>
>>54894672
If they were the same I wouldn't be triggered
>>
>>54894778
What do you want with sub-categories in set theory?
>>
Muh explicit error checking.
    gopath := os.Getenv("GOPATH")
absTmplDirname := filepath.Join(gopath, tmplDirname)
tmplDir, err := os.Open(absTmplDirname)
if err != nil {
return nil, err
}
defer tmplDir.Close()
tmplNames, err := tmplDir.Readdirnames(-1)
if err != nil {
return nil, err
}
var tmpl *template.Template
for _, tmplName := range tmplNames {
if tmpl == nil {
tmpl = template.New(tmplName)
}
absTmplName := filepath.Join(gopath, tmplDirname, tmplName)
tmplData, err := ioutil.ReadFile(absTmplName)
if err != nil {
return nil, err
}
if _, err = tmpl.Parse(string(tmplData)); err != nil {
return nil, err
}
}
>>
>>54894898
>current year
>using Go instead of a sane language
>>
>>54894792
I want set theory to go away
>>
>>54894898
>if err != nil { return nil, err }
>x4

Just use monads
>>
>>54894957
You can't dissect elements in category theory though.
>>
>>54894972
Just use exceptions.
>>
>>54895010
https://wiki.haskell.org/Exception#Exception_monad
>>
>>54895025
>Explicit exceptions
>Not using error
>>
>>54895066
>writing code that can have errors
>>
anyone know of any good work tracking software? Thinking of something similar to visual studio online with a backlog, sprints, breakdown charts, etc. Would just use trello but I need something a little more robust. Preferably free, but if I'm shooting in the dark here I'll just settle with VSOnline.
>>
>>54895081
safeDivide :: Int -> Int -> Either String Int


Why would anyone want to use a function with this signature?
>>
>>54895104
vim + markdown plugin
>>
>>54895172
Int -> NonZeroInt -> Int
>>
>>54895244
Int -> Int - { 0 } -> Int
>>
>>54895244
>>54895264
> -> Int
-> Rational Int Int*
>>
How good is Eclipse for C++ programming?
Thread replies: 255
Thread images: 27

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.