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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 314
Thread images: 42

File: UNIX MAGIC.jpg (155KB, 977x1488px) Image search: [Google]
UNIX MAGIC.jpg
155KB, 977x1488px
What are you working on, /g/?

Old Thread:
>>59594649
>>
FUCK LITERALLY ONE MINUTE OFF
>>
File: 1490560563345.jpg (69KB, 881x597px) Image search: [Google]
1490560563345.jpg
69KB, 881x597px
>>
File: 1484153592360.webm (3MB, 1236x700px) Image search: [Google]
1484153592360.webm
3MB, 1236x700px
>>
A social network for weebs.
>>
File: stinkpad.jpg (347KB, 1598x753px) Image search: [Google]
stinkpad.jpg
347KB, 1598x753px
>>59600079
Bought a ThinkPad today, just got Visual Studio installed, sitting on my couch doing some C++ practice problems with Cowboy Bebop on the TV in the background. I somehow convinced myself that getting a laptop would increase my coding productivity.

It hasn't, and I don't even care.
>>
Connect 4 in Java. /g/ memes were right about uni.
>>
In the Knapsack problem, you're supposed to put as much objects as possible, per their weights (values) in a knapsack of a fixed size.

Similarly to this, there is also another problem called the Bin Packing problem, where you need to put all the available items in as few as bins/knapsacks as possible, and again the capacity of one bin/knapsack is known.


I have a problem now that is similar to these two, but yet different a little bit. Contrary to the bin packing problem, where you want to minimize the number of bins, I now have the number of bins available beforehand, but the capacity of bins is the parameter that I want to optimize - namely, I want the capacities of all the bins to be as similar as possible, after I packed my items in them.

Is this a known problem, has it already been discused somewhere?
>>
>>59603501
or rather, the criterion that i want to minimize is the maximum capacity of the biggest bin, among the available bins that I am using.
>>
In C++, does std::end(arr[]) have to loop through the array somehow to find off-the-end, or is the operation constant in time?
>>
Writing network-facing code in C.
>>
first for c
>>
>>59603995
I think you can safely assume it's done in constant time with pointer arithmetic.
>>
>>59604727
You'll never make it, brainlet
>>
>>59604812
I think C should have its own safe heaven threads. No one likes C tards
>>
>>59604849
>safe spaCe general
>>
>>59604849
no.
I dont like c either, but hugbox threads are worse.
>>
rate my triangle thing.
http://pastebin.com/8L6BLFkc
>>
>>59604854
kek
>>
Implementing mechanism for feature flags on an angular 2 application using redux

Angular 2 a shit
>>
>>59604849
This thread is blessed by C from the OP.
>>
>>59604923
Is that why the thread is so dead?
>>
File: 1489911125711.jpg (37KB, 546x432px) Image search: [Google]
1489911125711.jpg
37KB, 546x432px
Good alternatives to C?
>>
>>59604946
What program are you trying to make? What project?
>>
>>59604946
There are none. C is the only truly portable language that can give you C-level performance.
>>
>>59604941
rekt
>>
>>59604956
>X is the only truly portable language that can give you X-level performance.
So this is the power of a C toddler
>>
>>59604952
Learning.
>>
>>59604956
>C
>Portable
>>
>>59604975
http://ddili.org/ders/d.en/
>>
>>59604941
No, it's alive, thanks to your autism screeching "How C is bad".
>>
>>59604994
All this started here >>59603851
Notice how the angry C manlet brought this up out of the blue
>>
>>59605003
>No
Now*
>>
>>59604946
Fortran
>>
File: xd.jpg (106KB, 1101x624px) Image search: [Google]
xd.jpg
106KB, 1101x624px
just released 0.0.1 of my i2p bittorrent client that is probably full of bugs
https://github.com/majestrate/XD/releases/tag/v0.0.1

needs a good logo tho
>>
>>59605023
use the gtorrent logo
>>
>>59600079
Nintendo DS homebrew.
>>
>>59604946
*crickets*
>>
>>59605014
I meant "No".
>>
>>59605023
>just released 0.0.1
literally who cares about a day 1 project
>>
>>59605097
You did
>>
>>59605118
only enough to call him a baka
>>
>>59605140
>autistic meltdown
>>
How do I make an iterator function for a metatable in Lua?
>>
Hi I'm a Cfag, should I learn POO?
>>
>>59605190
Only if it's CLOS or Smalltalk.
>>
>>59605190
POO is omnipresent, even if you're not willing to use it personally it's probably a good idea to actually learn the concepts and be able to explain them.
>>
File: 1490417162757.png (196KB, 1282x1055px) Image search: [Google]
1490417162757.png
196KB, 1282x1055px
>>59605190
No. You should learn the difference between char[] and strings
>>
>>59605160
Dumb anime poster.
>>
>>59605211
Take your pills.
>>
Writing software to help promote free speech. Going to use it to defeat Trump supporters and save america from Russian invasion
>>
>>59605264
Wrong board faggot >>>/pol/
>>
>>59605264
>implying Trump doesn't openly invite Putin to place his balls in his mouth.
>>
File: encouragedthought.png (19KB, 704x177px) Image search: [Google]
encouragedthought.png
19KB, 704x177px
well, what do you think c and non-c programmers?
>>
>>59605317
(((RUSKIY))) SHILL DETECTED

200 Rubles have been deposited in your Ruskiy Mir account, komrad :^)
>>
>>59605356
Here's the order of operations for C

http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm

Your professor is retarded
>>
>>59605400
Precedence isn't the same as order of evaluation, retard
>>
>>59605023
are gonna to keep fixing, developing and documenting this shit?
>>
>>59605420
Russians are not human. fact.

Please return to turnip farm, dmitry
>>
>>59605356
I would say that makes sense. Think about something like Amdahl's Law: always optimize for the common case, such as a small number (or only one) binary operator.
>>
>>59600588
Get linux, stop watching anime
>>
>>59605356
No I don't want to trade stability for anything
>>
C was a milkshake
ML was Robbin
>>
>>59605400
>Here's the order of operations for C
>http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm
Knowledge level: C toddler
>>
Just wrote a calculator with algebraic notation in rust, with a parser that should be extensible to arbitrary binary operators.

Am I doing the parsing thing right?

https://gist.github.com/anonymous/df510064839058571756b243d0173e7e
>>
>>59605517
That code looks beautiful
>>
>>59604994
It's just the usual retards. Report and ignore.
>>
>>59605517
Please rewrite it in a language that's actually readable, and ask again.
>>
>>59605545
That looks readable to me, are you sure you read any project that's not a fizzbuzz?
>>
>>59605517
Yeah that looks about right but you'll have to change the approach if you're gonna want to add support for variables and functions.
>>
File: clarification.png (25KB, 791x197px) Image search: [Google]
clarification.png
25KB, 791x197px
>>59605356
>>
>>59605542
>>59604849
>>
>>59605517
Example input into the repl:
( 2 + 7 ) * 5 / 3
Output:
Ok(Float(15))
The AST of your expression is: Ok("(* (+ 2 7) (/ 5 3))")
>>
>>59605517
That's the "hackish" way to proceed, writing the grammar in LL(1) form is more elegant.
>>
>>59605602
So angry
>>
>>59605568
All I see is
&!::<::>!->::=>::)()())::())&::
. I don't know what any of that means, so I can't read the code.
>>
>>59605517
Why do you need a {:?} ?
>>
>>59605602
Stop replying to him.
>>59605620
Please don't post if you don't have an'y meaningful contribution.
>>
>>59605620
>I don't know what any of that means,
Have you tried shutting your dumbass mouth when you are supposed to in that case?
>>
>>59605620
I guess that makes sense if you don't know any programming, how about you try to learn something first then before you read and judge other people's code?
>>
>>59605442
yes, i have a roadmap somewhere
>>
i'm trying to make a haskell script that i can use in bash to sort things, this is what i have
midpoint :: [a] -> Int
midpoint xs = length xs `div` 2

halves :: [a] -> ([a],[a])
halves xs = (splitAt $ midpoint xs) xs

merge :: (Ord a) => [a] -> [a] -> [a]
merge (x:xs) (y:ys)
| x < y = x:merge xs (y:ys)
| otherwise = y:merge (x:xs) ys
merge [] ys = ys
merge xs [] = xs

mergesort :: (Ord a) => [a] -> [a]
mergesort [] = []
mergesort [x] = [x]
mergesort xs = merge (mergesort a) (mergesort b)
where (a,b) = halves xs

main :: IO()
main = do
input <- getLine
let values = map read $ words input :: [Int]
print $ mergesort values


i used ghc --make sort to create the executable and i want to be able to do something like
echo "1 3 2" | ./sort
and it pop out 1 2 3 but it's not working. can someone tell me what i'm doing wrong?
>>
>>59605693
???? why not just use the sort you have on your system
>>
>>59605671
what ideas do you have for the logo?
>>
>>59605693
>mergesort of all things
>>
>>59605693
**i mean in the terminal. and i know there's already stuff to sort things, i'm just annoyed i can't get this to work
>>
>>59605693
PATH variable. Include your binary in your PATH
>>
>>59605736
none at the moment
>>
>>59605731
that's like asking why not just drive when i wake up in the morning and find i'm unable to walk.. it's not the point that i don't technically have to walk right now..
>>
>>59605764
that's a shit analogy
you want to sort things
there's a sort binary in binutils
use it

the correct analogy would be that you have a car in your garage and need to drive somewhere but instead you decided to make your own car
>>
>>59605783
Some one has to make cars
>>
>>59605783
That's unrelated to what he asked. You're shitposting.
>>
>>59605783
>you want to sort things
wrong.
>>
File: 1449709665970.gif (239KB, 500x419px) Image search: [Google]
1449709665970.gif
239KB, 500x419px
>Zygohistomorphic prepromorphisms
>>
I have a function that takes a long time to eval. I have declared a lot of new variables in it which I think is the cause of this problem. Would the performance be improved if I declare it outside of the loop first?
>>
>>59605941
MUH FEATURES
>>
>>59600202
very clean! github name?
>>
>>59600079
Building a web app to connect people (similar to a penpal matching service). Is Ruby and Sinatra still OK for something like that? Only have experience with Django/Python in the past
>>
File: I2P.jpg (131KB, 535x535px) Image search: [Google]
I2P.jpg
131KB, 535x535px
>>59605752
something like this?
>>
>>59606049
could work, where is the "XD" part?
>>
File: dpt.jpg (164KB, 800x1000px) Image search: [Google]
dpt.jpg
164KB, 800x1000px
As always.
>>
>>59605975
Show code/algorithm. Most compilers are very good at loop unrolling.
>>
File: 1475260740100.jpg (41KB, 374x374px) Image search: [Google]
1475260740100.jpg
41KB, 374x374px
I'm trying to make yacc (I worked it out on the lex part) work with %union and %type but it gives me an error on the $1 line whether or not I change it to $1.i. What gives? Why is yacc/lex such a pain?

%{
int yylex(); //needed to clear a compiler warning
int yyparse(); //needed to clear a compiler warning

#include <stdio.h>
#include <string.h>

//extern YYSTYPE yylval;

void yyerror(const char *str)
{
fprintf(stderr,"error: %s\n",str);
}

int yywrap()
{
return 1;
}

int main()
{
yyparse();
}

%}

%token NUMBER ASSIGN ID SEMICOLON EQ NE LT LE GT GE PLUS MINUS MUL DIV RPAREN LPAREN

%union
{
int i;
char *s;
}

%start ROOT
%left PLUS MINUS
%left MUL DIV
%left EQ NE LT LE GT GE

%type <char*> expr1a
%type <int> expr1b
%%

ROOT:
commands {printf("root\n");}
;

commands: /* empty */
commands SEMICOLON command
| command
;

command:
assign
;

assign:
ID EQ expr
{
printf("-assign\n");
}
;

expr:
| expr1 MUL expr1
| expr1 DIV expr1
| expr1 PLUS expr1
| expr1 MINUS expr1
| expr1 EQ expr1
| expr1 NE expr1
| expr1 LT expr1
| expr1 LE expr1
| expr1 GT expr1
| expr1 GE expr1
| LPAREN expr1 RPAREN //{$$=$1;}
| expr1
| expr1a
;

expr1:
expr1a
| expr1b
;

expr1a:
ID {printf("-expr(id): %s\n",$1);}
;
expr1b:
NUMBER {printf("--number: %d\n",$1);}
;


...
example.yacc:91:38: error: expected identifier before ‘char’
example.yacc:94:37: error: expected identifier before ‘int’
>>
inline void yield() 
{
detail::scheduler::thread_switch();
}

template<typename F> inline void yield_while(F condition)
{
while (condition()) yield();
}

template<typename T> inline void yield_until(T time_point)
{
yield_while([&time_point] { return T::clock::now() < time_point; });
}

template<typename C> inline void yield_for(typename C::duration duration)
{
yield_until(C::now() + duration);
}

hnnnngggg syntactic sugar
>>
File: ass_fuck.jpg (66KB, 655x489px) Image search: [Google]
ass_fuck.jpg
66KB, 655x489px
>>59606157
It's a root finding algorithm. I'm doing something like
void newton(double &s)
{
double h = 0.002;
double a = 0.0;
double a_temp = s;
double epsilon = 2.0e-4;

while(abs(a-a_temp) > epsilon)
{
a = a_temp;
double x = x(a);
double f = f(x,a);
double x_a = (x(a+h,b)-x(a-h,b))/(2h);
double x_b = (x(a-h,b)-x(a-h,b))/(2h);
double f_a = (f(x_f,a+h)-f(x_b,a-h))/(2h);
a_temp = a - f/f_a;
}
s = a_temp;
return s;

except that it's 2-dimensional, so I have pretty much pow(2) more "double" variable declarations inside the loop. Does this make a difference?
>>
What's so bad with OOP ?
I think it's pretty handy to have functions associated with certain datatypes and call them associated to those datatypes.
>>
>>59606350
that's exactly what it's good for and there's nothing wrong with that.
the problems arise when people go full java and spread out simple implementations across multiple functions/classes/files, and go out of their way to make things overly complicated by adhering strictly to fixed design patterns and principles.
>>
File: 7856786765.png (143KB, 700x700px) Image search: [Google]
7856786765.png
143KB, 700x700px
>>59606066
I tried but looks like shit.
Good luck with the project.
>>
>>59605534
Thanks!

>>59605570
I'm planning to extend it by adding unary functions and tuples at some point. The approach should keep working for that. You are definitely right about variables though.

>>59605590
I'm a greenhorn that hasn't faced any dragons properly before. I'll look into it.

>>59605626
I just use it by default without bothering to try {} when I'm debugging.
>>
>>59606342
Finding the the (or a) true roots of a function in n dimensional space is very difficult. I don't think your loop is the problem, it's probably that the function (newtons method) itself is 'seesawing' back and forth around a solution for a long time before settling down under your epsilon. You could print every 100 iterations and check for yourself.
>>
>>59606448
pgood / 10
i'll use it as a base maybe
>>
>>59606448
>/g/ - logos design
>>
>>59606573
WE HAVE FUCKING NIGGERS!
>>
>>59606547
Oh ok I guess I'll just go fuck myself. Thanks anon.
>>
>>59606547
it does seem like one would want to dig into the math some more. praying that newton works is usually not enough
>>
>>59606277
Nvm, I looked at other codes and realized I could have done
token <i> NUMBER
instead of %type
>>
>>59600225
So here?
>>
Question /g/uys
Need:
>Java cross-platform program
>Closed source(I'm not the one who chooses)
>GUI
What framework to choose?
>>
>>59606837
>Java
Do you even have much choice?
>>
>>59606848
I don't have any choice about Java nor closed source, I just have to select a framework that allows me to release it without being jewed.
>>
>>59606837
You got Swing (old and battle test) or JavaFX (newer, faster, fancier).

JavaFX came to late: Swing was already dying and continues to die. Neither of them are technologies you should invest time into.

If you just need a quick application without special requirements you want to use Swing.
>>
File: asdassss.png (61KB, 1690x544px) Image search: [Google]
asdassss.png
61KB, 1690x544px
sorry there is no stupid questions general rn

I wanted to do it the smart way but the output is random shit
>>
>>59604946
lisp, rust, go, swift
>>
>>59606938
>Neither of them are technologies you should invest time into.
I can understand about Swing, but what's so bad with JavaFX?
>>
>>59606938
I have the understanding that JavaFX limits me to release it commercially, right?
If I'm right JavaFX is out, gonna check swing now.
>>
>>59606960
I put the value 8
Later I get 7 (nb_petals -= 1)
I enter into the loop
7 is greater than 0
I get 1 (nb_petals = nb_petals - 6)
1 is greater then 0
I get -5 (nb_petals = nb_petals - 6)
-5 is less than 0
Return -5
>>
>>59605356
You shouldn't write big nested expressions all on the same line anyway (especially not ones with side effects), so it isn't even a tradeoff for me - leaving the order of evaluation unspecified is a win-win.
>>
File: 1478036727555.jpg (47KB, 645x968px) Image search: [Google]
1478036727555.jpg
47KB, 645x968px
>he thinks modulus returns the remainder
>>
File: sssassa.png (78KB, 1822x775px) Image search: [Google]
sssassa.png
78KB, 1822x775px
>>59607013

oh yeah im dumb
fixed it, now it passed
>>
>>59606960
like anon said, run this through in your head with a small number. think about conditions should really be met in order for the body of that loop to run. is it enough to just have some petals remaining?
>>
I learned HTML like a retard and still don't understand how positioning works.
Can someone explain it to me real quick?
>>
>>59607168
Not programming
>>>/g/wdg
>>
>>59607168
>>>/g/wdg/
>>
>>59607047
>>
File: epic (1).png (16KB, 333x308px) Image search: [Google]
epic (1).png
16KB, 333x308px
>>59600079
>Scheme with types
Is this it lads? Is this the final bogpill? The hammer AND the anvil? The perfect balance between expressiveness and performance?
>>
>>59607247
>only hygienic macros
>verbose as fuck
>no reader macros
I mean bigloo is good scheme implementation that supports real parallelism but fuck I hate how verbose scheme can be.
>>
I wanted to make a simple clock in C# but the console would sometimes pause and not output for a few seconds. Why does this happen?
>>
>>59607076
return phrases[np_petals % 6];
>>
>>59607219
They satisfy different equations, Anon
>>
>>59606960
>>59607076
When nb_petals > size of phrases, it's supposed to cycle so that for values of nb_petals between 7 and 12 would be treated the same for values 1-6.
Use the modulo operator to get this cycle.
nb_petals % length-of-phrases will give you a value between 0 and length-of-phrases.
std::string phrases[6] = {"I love you", "a little", "a lot", "passionately", "madly", "not at all"};
std::string how_much_i_love_you(int nb_petals) {
int idx = (nb_petals-1) % 6; //subtract 1 from nb_petals to shift idx from 1-6 to 0-5 for array access
return phrases[idx];
}
>>
>>59604727
Have fun reading papers from the 90's
>>
>>59607341
probably maybe it would work in javascript better
>>
>>59604727
all your base are belong to us
>>
>>59607299
verbose scheme code > unsearchable wannabe APL syntax puzzle-oriented langs like Haskell
>>
>>59607299
also you're wrong about macros
any popular implementation will give you access to classic lisp style macros
>>
File: logo-small.png (5KB, 190x88px) Image search: [Google]
logo-small.png
5KB, 190x88px
What does /g/ think of this?
>>
File: IMG_20170322_152359.jpg (760KB, 2448x3264px) Image search: [Google]
IMG_20170322_152359.jpg
760KB, 2448x3264px
can you help me with this scheme program

i need get 10 numbers (exactly numbers of pic related)
>>
>>59607847
Yeah, I'm also interested in it
>>
>>59607847
could be better
could be worse
>>
>>59607856

(take 10 coll)
>>
>>59607341
Post code.
>>
File: gcc1987.png (40KB, 817x674px) Image search: [Google]
gcc1987.png
40KB, 817x674px
gcc source code, 1987
even back then it was a mess of mixed tabs and spaces already.
>>
>>59607856
https://oeis.org/A002605
>>
>>59607856

furrySlave 0 x = 0
furrySlave 1 x = 1
furrySlave y x = 2*(furrySlave y-1 x + furrySlave y-2 x)

main x = range(0,x) map furrySlave _ x
>>
>>59607965
>it was a mess of mixed tabs and spaces
Who cares as long as it's readable?
>>
>>59608002

hey dude

(define (suc x)
(cond
[(= 0 x)0]
[(> x 1) (begin (display x) (display " ") (suc (* 2(suc (- x 1)+ suc (- x 2)))))]
[(= (x 1) 1) ]))
(suc (read))

you have a idea
>>
>>59607965
I'm more concerned by the dubious GNU indentation style
>>
>>59607894
How?
>>
>>59608106
why not

x > 1 (recur)
otherwise (x)
>>
File: QX1QC4B.jpg (59KB, 960x720px) Image search: [Google]
QX1QC4B.jpg
59KB, 960x720px
How do I learn QT?
>>
>>59608106
>square brackets
Why do you do this?
>>
>>59608204
reincarnate as a loli
>>
>>59608212

Talk in ya first language
>>
>>59608212
sorry i dont knowed this function of the chat
>>
>>59605517
Just added functions to my calculator. Adding support for them was straightforward. Just followed the types.

https://gist.github.com/anonymous/488ba44e7b21058f2e4dd2a5717a78eb
>>
>>59604946
Fortran, LISP.
The answer you want to hear is Rust.
>>59605021
This.
>>
File: dt170327.gif (128KB, 900x280px) Image search: [Google]
dt170327.gif
128KB, 900x280px
LOL
>>
>>59606078
>comparing a multi million dollar company to a 4chan thread
>does so using inaccurate MS Paint comic
>>
>C for low level libraries
>python for scripting
>no idea what language to use for mid level stuff
There's no good statically typed and compiled language that doesn't require huge vm like java.
>>
>>59608517
>C for low level libraries
>OCaml for anything else
FTFY
>>
>>59608517
> There's no good statically typed and compiled language that doesn't require huge vm like java.
C#
>>
>>59608517
sepples
>>
>>59608538
fuck of microshitter
>>
>>59608517
C++ for libraries / anything else
functional lang of choice for scripting
>>
>>59608558
What if I won't?
>>
>>59608066
help please !
>>
>>59608556
>>59608575
sepples sucks.
>>
>>59608578
use std::integer_sequence<>
>>
>>59608603
oh wow that's a good argument.
guess I'll stop using it now.
>>
>>59608603
its infinitely better than C, especially for libraries.
The second i start seeing THIS_VAR in libs i close the page.
>>
>>59606078
>C++
>efficient

>functional
>lisp
Underaged.
>>
>>59608619
>std::integer_sequence<>

is for scheme (dr.racket)
>>
File: xx.png (79KB, 1636x1000px) Image search: [Google]
xx.png
79KB, 1636x1000px
Hey /dpt/. i've been learning gtk for some time to get comfy in C, however it's very high-level and not the C i wanted to get comfy in. Also shipping 30 LGPL dll and half of linux tree is a bit of a stretch. And compiling them statically on Win is close to impossible and i don't plan to restore my virginity anytime soon. But i need the app to be fucking gui and have comfy theme similar to Arc. Should i learn C++ and switch to QT and leave C for critical algos?
>>
>>59608726
You can just write the core functionality in C and then slap a C++/Qt GUI on top of it (or QML for that matter).
>>
>>59606024
Halp
>>
>>59605693
import Data.List (sort)
>>
>>59608517
Rust/C++/Go
>>
are these rules the same?

A -> A B
A -> B


and

A -> B
A -> B A
>>
>>59608726
>>59608785
Can you not just make QT applications with C?

Correct me if I'm wrong but I think C++ is just C and there's no reason you need to use any of the C++ functionality if you don't want to
>>
What book for learning Python do you guys recommend if I'm somewhat well versed in basic C? I.e. I know the syntax and how to solve problems and implement simple algorithms (as I'm only a first year CS student).

Most books are either learning programming as a whole using Python (Learn Python the Hard Way) or aimed at already experienced programmers (Dive into Python). What are some in between books akin to that of 'C - A Modern Approach' or even something like K&R, but not fully reference material?
>>
>>59608839
No, that will not work.
>>
>>59608819
>Rust
Not really appropriate for programming, it's just a fashion statement language.
>>
sup guys, i want to create a really simple calculator program in C or Java, where do i start?
to make it clear: i know how to program algorithms that run on terminal, but i want something with graphic interface (ie calculator on windows) and that i can run without an interpreter
>>
>>59608884
It's a recent language. You can still do quite a lot with it.
>>
>>59608933
i want to do this but in fasm x64
>>
File: webdevs in 2017.png (240KB, 579x617px) Image search: [Google]
webdevs in 2017.png
240KB, 579x617px
Defend this.
>>
>>59608933
>GUI
>C
You are going to have hard time.
>>
>>59608942
i'm too casual for assembly huehue
>>
>>59608831
BUMPP
>>
>>59608952
thats a shame, i really love C
>>
>>59608952
>muh can't do gui without oop
you are just bad
>>
>>59608945
Just because it's complicated doesn't mean it's bad

JavaScript is crap and people are doing their best to solve problems and make it more powerful. Unfortunately that also means a headscratching mishmash of tools all serving different purposes on various different levels. It's not ideal but it's definitely a step forward

At some point it'll be more cohesive. Or we'll just jump ship and move onto a better language, god knows it should have happened 20 years ago
>>
>>59608945
what is there to defend?
>>
>>59609000
>#define
>#define
>#define
>>
>>59608839
I feel like it's a wrong tool for gui and in real world everybody uses Qt so i will have to learn it at some point anyway, might as well do it now. So there's no reason to spend time on gtk atm, although i like the project.
I think i'll take this anon's >>59608785 advice and feed C core to Qt client
>>
>>59609000
>>59609049
HWND
LPCTSTR
LV_DISPINFO
DWORD
NMHDR
>>
>>59609096
FLDSMDFR
>>
>>59608945
>Defend this
in node land this is lean
you better check out dependency list for react starter kit
>https://github.com/kriasoft/react-starter-kit/blob/master/package.json
>>
>>59608831
For writing a parser, yes. The second grammar rule set will always consume some of the input before recursing, while the first rule can get stuck in an infinite loop. They also obviously generate different parse trees for the same input.
>>
>>59609029
This
I have no clue what's going on
>>
>C#
>public string myproperty { get; set; }
defend this.
>>
>>59609153
That's probably one of the best idea of C#. That's a brilliant idea.
>>
>>59609153
What's to defend?
>>
>>59609153
What is this?
>>
>>59602953
i had to do a project like that last year. with the negamax algorithm or some stupid shit. so stupid.
>>
>>59609130
it looks like a list of dependencies... are we supposed to defend having dependencies?
>>
>>59602953
for me its a java database
>>
>#define
defend this.
>>
>>59609153
It is kind of silly, when you compare it to proper accessor generators (esp the attr_* decorators in ruby).

But hey, it's at least some sort of accessor shorthand. Some OO languages have pretty much none (ohai java with your boilerplate bullshit).

That said, modern meme languages (eg Boo) can do far better than this.
>>
>>59609259
preprocessor directive to autoreplace everything on the left with everything on the right
>>
>>59609259
>#define

It's the best you can do with single pass substitution, no AST. Fast compile times with minimum memory usage.
>>
>>59609192
literally a public variable. considered very harmful in oop-land.
>muh encapsulation
but call it a property and suddenly it's okay.
>>
>>59608933
Netbeans + Java Swing
Easy and good to start with.
>>
>>59609259
>#define defense

Last time somebody tried to "fix" #define, C++ happened.
>>
>>59608204
learn c++, the rest is trivial with a basic tutorial
>>
File: asm.png (36KB, 642x809px) Image search: [Google]
asm.png
36KB, 642x809px
Reading a crash course on IA-32.

if var is 7, shouldnt cmp [var], 7 result in 0 and thus set the Zero flag? If so, shouldn't the instruction be jnz instead of jz?
>>
>>59609313
I thought it was a public method declaration.
>>
>>59608839
thats VERY wrong
>>
>>59607168
flexbox
>>
>>59607847
May may.
No point mixing theorem proving with general purpose language.
>>
>>59608517
C++ desu.
t. POO doubter
>>
>>59609370
Looks like a typo.
>>
>>59609370
yes.
that is why civilized people use jne.
>>
>>59609370
Zero flag is set if result is zero. This is still moderately sane. If you want true mindfuckery, try ARM carry flag - which is set to 0 if the result underflowed with SUB, and to 1 if it overflowed with ADD.
>>
>>59609452
>>59609455
Alright, thanks
>>
>>59609470
Keep this table bookmarked, helped me out more than once.
http://unixwiz.net/techtips/x86-jumps.html
>>
>>59609461
Haven't learned about ARM ISA yet but I'm going to start reading this book https://beginners.re/ after I finish the crash course and it covers it.

>>59609519
Cheers!
>>
@(function fizz_buzz () ((str fizzbuzz "fizzbuzz\n") (str fizz "fizz\n") (str buzz "buzz\n") i)
(while (< i 100)
(begin
(if (and (== (% i 5) 0) (== (% i 3) 0))
(print fizzbuzz 16)
(if (== (% i 5) 0)
(print buzz 8)
(if (== (% i 3) 0)
(print fizz 8)
(print_num i))))
(= i (+ i 1)))))

would you code in such a language
for your local variables in a function you need to declare them before you use them and you can't declare them whenever you like just in the beginning after you've declared your arguments to the function
>>
>>59609671
What
>>
>>59609671
I use Ada and C, so yes.
>>
>>59609691
fizzbuzz fizz and buzz are variables you need to declare
they are 'str' type, meaning a 32bit int pointer to a char, i is just a 32 bit int

after you're done declaring them you can't declare any more local variables
>>
>>59600588

> visual studio

you're better than that.
>>
>>59609699
Good, now prohibit all recursion except in tail call position
>>
@(function fibs (n) () 
(if (< n 2)
n
(+ (fibs (- n 1)) (fibs (- n 2)))))

recursion is allowed, but tco isn't implemented
>>
>>59609671
>>59609765
So, where are all defmacros for CL?
>>
I wrote up some example problems for a friend to help them practice before an interview. They are second year CS, not great at programming. What does /g/ think of these problems? Too easy?

1a)
Write a function that takes a string 'str' and a string 'delim'. It should return
the part of 'str' before the first occurence of 'delim', *including* the delimeter.
If it doesn't occur in the string, return the entire string.
e.g.
before("hello, world", ", ") => "hello, "
before("abcdefg", "z") => "abcdefg"


1b)
Write a function that takes a string 'str' and a string 'delim'. It should return
the part of 'str' after the first occurence of 'delim', *not including* the delimeter.
If it doesn't occur in the string, return an empty string.
e.g.
after("hello, world", ", ") => "world"
after("abcdefg", "z") => ""


2)
Write a function that takes a string 'text' that contains some paragraphs. It should
return the text with sentence capitalization fixed, meaning that the character after the end of each sentence should be uppercase. Assume that periods only occur
as the end of a sentence, and are always followed by a single space.
e.g.
fix("hello, world") => "Hello, world"
fix("hello. good morning. ") => "Hello. Good morning. "
fix("") => ""

3)
Design a 'Drive' class (plus any additional classes), which represents a user's "drive" (like Google Drive).
A drive holds an assortment of named (text) documents. Write functions to add new documents, and a function
that prints out the names of the user's documents.

3a) Make it so that the listing indicates (with "[!]") if any documents don't have correct capitalization. Create
a method in Drive that automatically fixes the capitalization of all of the user's documents.

3b) Allow a Drive to contain pictures, as well as text documents. Do not try to "correct capitalization" of pictures,
but still print out the name of the pictures alongside the other documents.
>>
>>59609765
git clone https://github.com/ocaml/ocaml.git
cd ocaml
git checkout 4.04.0
./configure -prefix /opt/ocaml-4.04.0
make world
make bootstrap
make opt
make opt.opt
make install
>>
>>59609882
s/make i/sudo make i/

FTFM
>>
File: 1489379427237.png (117KB, 464x810px) Image search: [Google]
1489379427237.png
117KB, 464x810px
What do you think about stuff like KolibriOS and BaremetalOS.
>>
>>59609877
What, do you mean Common Lisp, it only looks like cl because that syntax is easy to parse and compile to asm
I haven't made macros yet, but that's just text replacement right
>>59609882
I don't follow, quite
>>
def starting_balance():
print('Please enter the starting balance of the account: ', end='')
while True:
try:
balance = float(input())
break
except ValueError:
print('Please enter a valid number: ', end='')

print('\nThe starting balance is:', format(balance, '.2f'), '\nIs this correct? (y/n) ', end='')
y_n = input().lower()
if y_n == 'y':
print(balance, type(balance)) #float <class float>
return(balance)
else:
del balance
starting_balance() #restart function

balance = starting_balance()
print(balance, type(balance)) #None <class NoneType>


Can anyone point out to me why this returns none if you select n for the first y_n choice but y for the second?
>>
>>59609950
>I don't follow, quite
Recursivity is allowed and TCO is standard.
>>
>>59609966
In ocaml, yes

I know ocaml is a good lang
>>
REMINDER TO REWRITE EVERYTHING IN RUST
>>
>>59609988
Thanks anon. You are the real human bean
>>
>>59609880

Stop spoonfeeding that faggot there is no excuse
>>
Post your fizzbuzz here
https://codeshare.io/aJ7vZy
>>
>>59609985
So stop LISP and use last ocaml version
>>
>>59609988
Has someone wrote a c flavor in rust yet?
>>
>>59610015
only looks like lisp
I made a compiler for it, I didn't intend for it to be good
>>
File: xx.jpg (47KB, 564x499px) Image search: [Google]
xx.jpg
47KB, 564x499px
>>59609988
i'm not into fashion sorry
>>
File: 1486048909063.jpg (41KB, 484x361px) Image search: [Google]
1486048909063.jpg
41KB, 484x361px
>>59610127
girl (male) programmers can be into fashion and still be just as good as men (male) programmers
>>
>>59610127
If you ever had to come out of your basement you would
>>
>>59607965
Why is there so many CAPS functions and variables?
>>
>>59610143
>be into fashion
>good coder

pick one
>>
>>59610156
I pick not being a virgin
>>
>>59610167
then you are a shitty programmer
>>
File: xx.jpg (22KB, 600x325px) Image search: [Google]
xx.jpg
22KB, 600x325px
>>59610143
>>59610146
you see it's leaders, and it's followers. but i'd rather be a dick than a swallower
>>
Lightweight Outlook replacement as the company i work for went with E1 licenses but wanted an Outlook-like client.

Background workers keep getting hung when making multiple EWS calls at the same time (never triggers completed event). Anyone else encountered this?

Current workaround:
If (callInProgress){
Thread.Sleep(1000)}

C#, using MS EWS Managed API 2.2.
>>
int e = 0, f = 0;
((1 < 2) ? e : f) = 1; //valid

>terniary operators return lvalues
lmao let me just obfuscate my code sempai
>>
>>59610222
Is this meme++ or something?
C's ternary operator definitely doesn't return an lvalue.
>>
>>59610254
>C's ternary operator definitely doesn't return an lvalue.
>C
who cares?
>>
File: SumatraPDF_2017-03-28_02-13-35.png (19KB, 867x349px) Image search: [Google]
SumatraPDF_2017-03-28_02-13-35.png
19KB, 867x349px
>reading B Stroustrup book
why he du this?
also what is good modern 200-250 page book to get me up to speed in C++14 or later?
>>
>>59610267
the & and the * belong next to the variable
like
char* string_name and NOT char *string_name

the star is part of the type, not part of the name

the bracket thing is irrelevant
>>
>>59610254
>meme++
yes
>C's ternary operator definitely doesn't return an lvalue.
are you sure? they return rvalues as well in c++
int e = 0, f = 1;
((1 < 2) ? e : f) = (1 < 2) ? f : e;//also valid
>>
>>59610261
>are you sure?
Yes. I tried compiling it just now, and GCC complained.
>>
>>59610335
Replied to the wrong post: >>59610316
>>
What's the worst part about programming? Does it get boring? Is it mind numbing?
>>
>>59610335
sounds like a rogue compiler. have you tried using vs?
>>
>>59610294
char* string_name, string_name2


is string_name2 a pointer or a char???
>>
>>59610354
>sounds like a rogue compiler.
No. GCC is actually compliant to the C standards. Clang complains too.
If VS is accepts it, they're the ones allowing invalid code.
>>
>>59610359
i think it's a pointer too, or it should be
char* (str1, str2) would make sense and make it clear, though that doesn't exist
>>
>>59610359
you ll figure that out when you spend a day catching a bug
>>
File: 1488298966899.jpg (105KB, 658x661px) Image search: [Google]
1488298966899.jpg
105KB, 658x661px
Is it possible to make a calculator with GUI in assembly?
Some tips to make it?
>>
>>59610345
The worst part is that nobody appreciates what you do and your job can easily (!!!!!) be replaced by a pajeet who drives down the wage floor, hates programming and only does it for the money to feed his family back home.
>>
>>59610377
it's char m8
>>
>>59609960

Wait I've got it, I needed to return starting_balance()
>>
>>59600079
Rate my Fizzbuzz
for (var i = 1; i <= 100; i++) 
{
if (i/3 % 1 == 0)
{
document.write("Fizz") + document.write("<br />");
}
else if (i/5 % 1 == 0)
{
document.write("Buzz") + document.write("<br />");
}
else {{
document.write(i + "<br />");
}
}
>>
>>59610411
well that's not very logical
i have limited experience with C and would never declare variables like that

but i see your point about where the star should be, still don't like it though
>>
>>59610430
>webshit
fail
>doesn't even work
FAIL
>>
>>59610430
>{{
>>
>>59610457
It was added when I posted it.
>>
File: 1489847877652.jpg (39KB, 423x406px) Image search: [Google]
1489847877652.jpg
39KB, 423x406px
>>59610444
don't hate the player, hate the game, it makes sense to us oldfags who didn't grow up with syntactic sugar
>>
>>59610393
>Is it possible to make a calculator with GUI in assembly?
Absolutely.
>Some tips to make it?
Depends on the system.
>>
>>59610155
>idiomatic C
>>
>>59610345
trying to decipher other people's code
>>
>>59610155
>>59610489
It's convention for showing that something is a macro.
I think languages like Java using it to show a constant as well.
>>
I wish every language had tuples along with all the nice sugar that goes along with them. There is literally no reason not to have them in a modern language.

I also wish that every statically typed language had Algebraic Datatypes and Pattern matching on them.

Both are great features that work well with any given paradigm. They make your life more convenient, and your programs become more strongly typed. Win/win.
>>
File: 1487015936178.png (302KB, 1920x1080px) Image search: [Google]
1487015936178.png
302KB, 1920x1080px
Put on your socks and let's do one of these.
>>
>>59610526
no, trying to maintain other peoples code is the worst
>>
>>59610536
> It's convention for showing that something is a macro
Why it has to have so many macros?
>>
>>59610559
that's what I mean.
>>
>>59610570
that's apparently the best thing C's type system has to offer.
and it's not even part of the type system.
>>
>>59610570
You'll have to ask Stallman about that.
>>
>>59610555
i've done most of those

just not an imb interpreter, because i don't get what i'm supposed to do

and some of the games, because who cares
>>
>>59610482
Windows X64
>>
>finished compiler for class project
>realized it builds arguments lists backwards
>decide to just reverse it to make it more readable
>works for single depth argument passing, but no deeper
>instead of fixing the AST I just didn't create methods that took argument lists that weren't palindromes
>professor never noticed and I got an A
>>
>>59610597
Stallman thinks C is a lisp.
>>
>>59610704
>>works for single depth argument passing, but no deeper
>got an A
holy hshsit

you should feel shame
>>
>>59610704
>>59610790
I don't think many professors care about the quality of class projects, they rather care about the speed of accomplishing the task.
>>
>>59610704
You're ready for the industry coding.
>>
New thread:

>>59610823
>>59610823
>>59610823
>>
>>59605208
>Difference between int and a short
Can I tell the interviewer to fucking use stdint.h or will I lose marks?
>>
>>59610080
Will you post the source?
Thread posts: 314
Thread images: 42


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.