[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: 322
Thread images: 43

File: 147839988393947s.png (37KB, 165x200px)
147839988393947s.png
37KB, 165x200px
What are you working on, /g/?

Old thread: >>59414582
>>
Programming sans I/O
>>
>>59418657
Macros.
>>
What language would /g/ use to embed in a game engine?
I want alternatives to Lua.
>>
>>59418724
Guile Scheme.
>>
>>59418724
Javascript
>>
>>59418735
Already done that, but I need an alternative for Winslows.
>>
>>59418450
>>59417081
Perhaps it helps to see lambdas in a language that isn't Lisp?
https://www.lua.org/pil/6.html
foo = function (x) return 2*x end
>>
>>59418746
Embeddable Common Lisp
>>
>Serialize my neural network
>200mb file
>Try to open it out of interest

>Sublime
Watch as stack fills up to x86_u32
Crash

>Atom
Freezes
Crash

>Download GVim out of desperation
Opens
Lightning fast scrolling

Does this species deserve the coming environmental disaster?
>>
>>59418748
Now redefine foo so you can pass in a list of functions and a list of values, and apply each function to the list of values. Not trying to put you on the spot, but that'd make for a more accurate comparison.
>>
>>59418773
Try jEdit
>>
>>59418759
For a game engine? Really?
Thought Scheme was a better option
>>
>What are you working on, /g/?
A quiz app in QT for school presentation, where you load questions from a file and display them in random order on full screen. I know some basics of C, Python and C++, but I never done anything gui related. I grabbed some tutorials on QT a few hours ago, just finished reading them, and now I'm going to write the app. Hope it's going to be as easy as it looks. I might ask some questions later. Wish me luck.
>>
Is anyone familiar with the Canvas class in Java? Say I have 2 ball objects of a certain radius and put them in an arraylist. How could I check if other objects hit them (or get near them).
>>
>>59418794
Scheme is a smaller language, so that's probably why that idea gets commonly passed around. ECL can run on a variety of systems though, including windows.
>>
I made a basic sidescroller and pong in 2002 Borland Delphi and now I want to kill myself.
>>
>>59418842
good luck
>>
Best monospace font?
>>
>>59418825
That is a whole programming topic and has nothing to do with Java or Canvas.
You're looking into collision detection. You may iterate through two balls, but as the number of balls increase, your application will go slow.
>>
>>59418860
I'd say terminus but I don't think you can make it bold.
>>
>>59418856
Good luck as a Object Pascal game developer or killying myself?
>>
>>59418875
aren't they basically the same thing?
>>
>>59418724
https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Embeddable_languages

Or make a custom bash-like dialect, or add any interpreter as a server backend, but really, what the actual fuck do you want anyway?
>>
>>59418873
Nevermind, apparently you can bold it with 10px, 11px, and 12px.
>>
>>59418889
I managed to create an ingame repl with Guile, and I use that as a debug console.
Each object's script describes a module with its own (init) and (update dt).
Since Guile on Windows is shit, I wanted to provide another language for scripting and repl, but I wanted something small and fast enough.
>>
>>59418773
/dpt/ has been telling you since its inception, vim in the best text editor out there
>>
File: 1484954216270.jpg (421KB, 850x600px) Image search: [Google]
1484954216270.jpg
421KB, 850x600px
What terminal do you use?
>>
>>59418944
AngelScript?
Squirrel?
mRuby?
>>
>>59418989
A Lisp REPL.
>>
File: 827.png (250KB, 680x638px) Image search: [Google]
827.png
250KB, 680x638px
IT ALL
RETURNS
TO NOTHING
>>
>>59419011
I liked AngelScript, will try
>>
>>59418989
MobaXterm
>>
File: always try your best.png (390KB, 619x346px) Image search: [Google]
always try your best.png
390KB, 619x346px
>>59418989
GNOME
>>
File: Untitled 1.png (65KB, 332x277px) Image search: [Google]
Untitled 1.png
65KB, 332x277px
Im trying to build a color picker.

idk if Im doing this right but theres six different colors on a hue slider that you interpolate between. Whats the math behind transitioning between these 6 colors?

Language is python but it doesnt matter
>>
>>59419078
7 color values*
>>
>>59418657
working on patch system backend
the idea is to automate the release process by creating a patch from a set of files automatically or check them out from VCS
network protocol will work kind of like bittorrent to reduce bandwidth costs
>>
>>59419078
https://en.wikipedia.org/wiki/HSV_color_space
>>
Kotlin
>>
>>59419145
Włocławek
>>
File: butts.png (2KB, 359x83px) Image search: [Google]
butts.png
2KB, 359x83px
>>59418989
>>
C was a mistake
ML was robbed
>>
>>59418989
urxvt.
>>
>>59418989
It's just terminal.
>>
>>59418989
VT-220
>>
>>59419179
Why do you keep posting this? Is that 4 times today?
>>
>>59419241
if you repeat it enough, history will be undone
>>
>>59419241
I am angry at the years that were stolen from me
>>
>>59419214
didn't these things cause actual cancer because they weren't ray shielded like TVs?
>>
>>59419389
everything fun causes cancer
>>
File: done.png (85KB, 1082x410px) Image search: [Google]
done.png
85KB, 1082x410px
>>59419126
twas a lot of text. i decied to split the bar into 6 different sectors and add and subtract the remainders of 1-6 as the color values.
>>
>>59419415
No, only the degenerate shit that's been pushed in the last 100 years by jews
>>
>>59419420
>>59419420
HAM WAS A JEWISH CONSPIRACY
THEY KNEW ALL ALONG
https://www.theguardian.com/society/2015/oct/26/bacon-ham-sausages-processed-meats-cancer-risk-smoking-says-who
>>
CoffeeScript
>>
>>59419550
no
>>
File: 1488920460132.png (818KB, 1280x719px) Image search: [Google]
1488920460132.png
818KB, 1280x719px
Holy shit, I didn't know SICP was that hard. I understand the theory, but I'm unable to do the exercises. So I ditched the book. The next book on my list was: HtDP. It's written clearly, but it's too easy. So scratch that one off too and scratch off Scheme completely.
Back to the pinnacle of PL: Haskell. I hated LYAH and liked the wikibook although the wikibook is a bit short on explanation. During my quest to find a good book on FP memes, I've found the following book: Haskell Programming from First Principles. It looks understandable and I could even solve a few questions with my basic knowledge of Haskell. It looks even better because this cute lady called Karenis reading it.
Is Haskell Programming from First Principles any good for a beginner?
>>
Okay, holy shit, I only need to finish the 'stylesheet' loading and applying and some basic ui object types and we'll be live baby
>>
>>59418724
Why would you want alternatives? It's the only language really built exactly for that purpose.
>>
>>59419670
>pinnacle of PL: Haskell.
LOL
>>
>>59419670
Are you just reading books that are held by anime girls?
>>
>>59419670
what parts do you need explaining?
>>
>>59419670
>I hated LYAH
Why?
>>
So /g/, recently I started a little project and I chose to use Python (mostly because it's easy and has tons of libraries). Out of curiosity, didn't you guys hate Python and why?

Note: I learned the basics of programming (as in: I know quite well some languages and even some theory but never programmed anything noteworthy) two years ago, then did nothing for a long while, so I'm a little rusty, go easy on me.
>>
>>59419736
Because Lisp does everything better.
>>
File: 1376605057143.jpg (48KB, 454x603px) Image search: [Google]
1376605057143.jpg
48KB, 454x603px
>>59419670
Dumb anime poster.
>>
>>59419708
I just wanted something different.
Something that would not use OOP.
For that Scheme worked pretty well
>>
>>59419736
>Out of curiosity, didn't you guys hate Python and why?
Usual reasons:
> signifiant whitespace
> OOP
> self self self self
> "there is only one way to do it" bullshit
> "we're all consenting adults here" bullshit
> zen of python
>>
>>59419670
http://www.seas.upenn.edu/~cis194/fall16/
This is better than LYAH
>>
>>59419722
A bold supposition, but what if:
>he doesn't read those books at all and just watches anime instead?
>>
>>59419736
>and why
MEANINGFUL WHITESPACE
>>
>>59419736
python is a pretty cool thing as long as no one forces you to use it against your will
>could be said about anything, but whatever
>>
>>59419759
>we're all consenting adults here bullshit

what
>>
>>59419722
people who make SICP anime girl images have never read SICP

same with K&R
>>
>>59419808
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html

Use Ctrl-F
>>
what can I program that will make a lot of moneyy
>>
>>59419808
Google it, it's quite common in python /lit/.
>>
>>59419839
Why does this bother you?

Private class members should not exist.
>>
>>59419729
not him but LYAH feel apart around chapter 12. plus there's not really any practical applications in there
>>
>>59419873
your first mistake was thinking haskell could be used for solving real problems
>>
File: 1488142836814.jpg (18KB, 474x473px) Image search: [Google]
1488142836814.jpg
18KB, 474x473px
>>59419832
Don't project your own issues on other people.
>>
>>59419852
A program that redirects rounding errors to a swiss bank account. Be sure to carry it on a floppy disk and walk in like a boss when going to work tomorrow.
>>
>>59418889
>make a custom
JESUS STOP RIGHT THERE

Making your own language is interesting and fun, but it sure isn't productive, and it's a huge fucking pain in the ass for everyone except you.

No matter how shitty your chosen embedded language is, it's better than a custom one:
>has web resources
>has existing libraries
>relatively bug free in code paths you don't personally trigger

Think PHP v2 was shitty? Your custom language will be worse to everyone except yourself.
>>
>>59419852
learn COBOL
>>
>>59419881
I've written a http server in Haskell so idk
>>
>>59419775
kek
>>
>>59419896
how well does it run?
>>
>>59419892
If you read to the end of it you would have been able to tell that I was being facetious.
>>
>>59419852

Financial applications. Find someone with deep pockets who has a burning need for something and enterprise up a solution for them
>>
>>59419867
hurr durr
>>
>>59419896
show the code
>>
>>59419923
There is no reason why you should be hiding class members from others in your code.

If you need to obfuscate implementation details for the purposes of backwards compatibility or retardproofing, you use pointers to opaque types.
>>
>>59419919
such as what?
>>
>>59419955
durr hurr hurr
>>
>>59418657

ricing xd
>>
>>59420050
you anime nerds need to get girlfriends
>>
>>59420050
This is the programming thread you desperate (you) slut manchild
>>
>>59419711
Compared to other languages with a userbase > 1, it's pretty good.
>>59419722
I also bought headphones because the reviewer had an anime wallpaper.
>>59419723
I get completely stuck at questions. I don't even have a clue where to start. I could go on reading the book and find exercises elsewhere, but I don't know if that's worth the effort.
>>59419729
>some examples don't work
>no exercises
>>59419756
Dumb cartoon poster.
>>59419760
How does it compare to a 'real' book?
>>
>>59420050
is there a bigger waste of money than building a computer with high-end parts and then running GNU/Linux on it?
>>
>>59420134
which questions? the wikibook ones?
>>
>>59420143
Yes.
Installing an inferior goonix operating system such as arch on it and using a wallpaper with your shitty waifu from a retarded show. Not to mention the 3/10 rice.
>>
>>59420134
>I understand the theory, but I'm unable to do the exercises.
>understand
>but unable
It doesn't work like that. You do realize you need to read a book like that carefully and thoughtfully, right? It's not your Jap comic books

>read a chapter part
>try exercises
>nope.jpg
>read a chapter again
>try again
>try again
>ask /dpt/
>try again
>while (!learned) {...};
It's called learning, yknow
>>
>>59420166
No, the exercises in SICP. Amazingly, I finished all the exercises in: Haskell Basics, Elementary Haskell and Intermediate Haskell. Some took a while, but I got them all. I haven't started the Monads chapter yet.
>>
Guys where are the generic arrays in Java I can't find them!

Guys?
>>
>>59420143
highend cpu helps with compiling shit tho
>>
>>59418989
powershell is the best
>>
File: 1488459447829.gif (2MB, 360x360px) Image search: [Google]
1488459447829.gif
2MB, 360x360px
>>59420208
oh, Lisp is weird
keep up the good work with Haskell
>>
int *array = (int*) malloc(3);
*(array + 0) = 45;
*(array + 1) = 67;
*(array + 2) = 89;
printf("%p\n", &array[2]); // 0x560f537ac018
printf("%p\n", &(*(array+1))); //0x560f537ac018
printf("%d\n", *(&(*(array+1)))); // 67
int *arrayPtr = &(*(array+1)); // adresa catre 67 adica 0x560f537ac014
printf("%d\n", *(arrayPtr+1)); // 89


How the hell does *(&(*(array+1)))) is equivalent to *(array + 1) or array[1] mean 67 ??!

I mean, array is the pointer to the first int.So plus sizeof(int) * 1 and dereferenced gives the adress where 67 is stored.Good.

Now comes the part where I can't understand.How the hell does &(*(array+1)) give the adress of the second element from the array, How does the compiler know?What if I had multiples variabiles that hold 67, how would the compiler know which adress to give!?!!

Thanks in advance.
>>
File: 1488906206376.png (666KB, 666x666px) Image search: [Google]
1488906206376.png
666KB, 666x666px
>>59420050
>pixel-perfect fonts with no signs of some cleartype
Perfect!
>>59420143
>>59420190
What kind of world problems do (You) both solve on your machines?
Desperately trying to make fun of anime fans on the anime website?
>>
>>59420224
a simple makefile cuts down on recompilation time immensely

or do you mean to say that installing gentoo is your primary use for a computer?
>>
>>59420259
>doesn't write resource intensive software
>can't play video games
>anime doesn't require more than a 10 year old core2duo to play correctly
>literally spend your whole day in a text editor editing your configs rather than doing anything interesting

satania is a shit meme
>>
File: harmful.png (88KB, 906x836px) Image search: [Google]
harmful.png
88KB, 906x836px
>>59418989
I use Alacritty. GPU accelerated terminal emulator written in Rust. Can't outmeme me.

It doesn't have scroll functions, so I really need to screen/tmux
>>
I'm learning what
int const * ptr; 
const int * ptr;

contst * int ptr;

const int * const ptr;



and
const * int * const ptr;


mean. The differences between them. Hard stuff :3
>>
File: 14888055594900.jpg (692KB, 2560x1600px) Image search: [Google]
14888055594900.jpg
692KB, 2560x1600px
>>59420249
>oh, Lisp is weird
It's not much weird, just make yourself comfortable with the idea that everything is the list and the first element in the list is some function with parameters in the rest cells.
>>
I do realize that I have to put some effort into it. Especially as a newbie. However, my brain shut down after reading this:
Exercise 1.7: The good-enough? test used in computing square roots will not be very effective for finding the square roots of very small numbers. Also, in real computers, arithmetic operations are almost always performed with limited precision. This makes our test inadequate for very large numbers. Explain these statements, with examples showing how the test fails for small and large numbers. An alternative strategy for implementing good-enough? is to watch how guess changes from one iteration to the next and to stop when the change is a very small fraction of the guess. Design a square-root procedure that uses this kind of end test. Does this work better for small and large numbers?

>>59420249
I think I'll pick up Haskell again. It can frustrate the hell out of me, but I know I'm the one to blame.
Scheme is funky, but I don't consider it a bad language.
>>
>>59420254
By definition, *(array + 1) is equivalent to array[1].
Also by definition, &*array is equivalent to array.
If you bother going through the steps, you'll see that it simplifies down to that.
>>
>>59420328
1 and 2 are the same, it's a pointer to a const int

i'm not sure 3 is syntactically correct

4 is a const pointer to a const int

5 isn't valid either

what resource are you learning from, stop it immediately
>>
>>59420344

Can you go through the steps to prove this please?
>>
>>59419757
You don't have to use OOP with Lua... It's powerful enough to support any paradigm. I have some libraries written that support a lot of functional-esque features like generator functions using coroutines, containers, higher order functions, function composing and currying, etc.
>>
>>59420361
Do your own homework, you CS weenie.
>>
>>59420340
> everything is the list
"Everything is a binary tree, but we still call it a list because we have been out of touch with CS for 50 years now"
ftfy
>>
>>59420357
I am re-reading my notes. I probably took them wrong. I was using the book "understanding and using c pointers".
>>
>>59420367

I tried, this is why i'm here
>>
>>59420376
reread it again

it should be
int *ptr
const int *ptr
const int *const ptr

anything else is malformed C
>>
File: 1486171027966.jpg (38KB, 753x543px) Image search: [Google]
1486171027966.jpg
38KB, 753x543px
>>59420299
>doesn't write resource intensive software
So?
>can't play video games
Proofless claim and the false one.
>anime doesn't require more than a 10 year old core2duo to play correctly
In 4K? Not even FullHD is played without problems.
>literally spend your whole day in a text editor editing your configs rather than doing anything interesting
People may be interested in editing configs in a text editor, haven't you thought about it?
>>
>>59420357
can't you make a constant pointer to a non-constant variable?
>>
>>59420328
>>59420357
5 should be
const int * const * ptr;


So yeah, wrong notes.
>>
>>59420380
he already told you the answer
*&ptr is equivalent to ptr
just cancel them out, you can manage that at least, right?
>>
>>59420375
>what are traditions
>>
>>59420458

>*&ptr is equivalent to ptr

Yea , but WHY??!

I don't learn like a parrot, if I cant understand how it exactly works down to the core, I cant learn.
>>
>>59420449
int *const ptr

sounds pretty useless desu
>>
>>59420471
* is the dereference operator
it dereferences a memory address
a pointer is a memory address
* lets you see what a memory address points to
& is the address operator
so dereferencing a memory address gives you the same pointer you just got the address of
>>
>>59420471
* (dereference) and & (reference) are inverses of each other; they cancel each other out.
&* follows a pointer somewhere, then take the address, giving you that pointer back.
*& takes a pointer to somewhere, then immediately follows it to where you started.
>>
>>59420471
& = *^(-1)
>>
>>59420254
&(*(thing)). Yes *thing might be 67, but why wouldn't the reference of that be the second array location?

int t = 64;
int v = 64;


Would &t be the same as &v? No. Values bind to memory spaces, when you say &(*value) you are saying give me the address as an integer of the variable *value, which is just a memory location. The only time *value becomes 67 is when it is used as an expression (rvalue). Does *value = 12 set 67 to 12? No. Learn to differentiate variables as memory locations and rvalues.
>>
>>59420471
*&ptr means you create a pointer (*ptr) and you follow the pointer to the address of *ptr (*&).
That's equivalent to the address of *ptr.

& means the address of. So *&ptr, means the address of *ptr.
>>
File: 1489255252163.jpg (54KB, 500x480px) Image search: [Google]
1489255252163.jpg
54KB, 500x480px
>>59420496
>>59420501
>>59420521
>>59420536
>>59420558

Thanks
>>
>>59420604
dumb frogposter
>>
>>59420604
i feel like deleting my answer now

dumb frog poster
>>
File: 1476073511692.jpg (89KB, 700x525px) Image search: [Google]
1476073511692.jpg
89KB, 700x525px
#lang racket

(define sum
(lambda (x)
(if (null? x)
0
(+ (car x) (sum (cdr x))))))

(define product
(lambda (x)
(if (null? x)
1
(* (car x) (product (cdr x))))))

(define hi-fun
(lambda (x y)
(if (null? (cdr x))
(cons ((eval (car x)) y) null)
(cons ((eval (car x)) y) (hi-fun (cdr x) y)))))

Why does running
(sum '((sum (hi-fun '(sum product) '())) 2 3 4))

gives me an error despite
(sum (hi-fun '(sum product) '()))

being OK?
Why I must to perform this?
(sum (cons (sum (hi-fun '(sum product) '())) '(2 3 4)))
>>
File: unnamed.png (91KB, 300x300px) Image search: [Google]
unnamed.png
91KB, 300x300px
I want to start learning Ada does anyone have any good pointers to where to learn it
>>
>>59420637
Apply for a job with the NSA.
>>
File: Irl_kike.jpg (56KB, 588x647px) Image search: [Google]
Irl_kike.jpg
56KB, 588x647px
>>59420645
I'd be right happy to!
>>
>>59420637
Read Programming in Ada 2012, on libgen
Read the Reference Manual, on Google
>>
>>59420617
one more thing,doesnt [] have higher precedence than & even as a rvalue?
>>
>>59420734
Cheers chum
>>
File: 1474325315193.jpg (44KB, 636x616px) Image search: [Google]
1474325315193.jpg
44KB, 636x616px
Employed Haskell programmer here :)
>>
>>59420778
What's the big deal with monads?
>>
>tfw no haskell gf
is it possible to code an ai gf in haskell?
>>
>>59420753
ptr[2] is *(ptr + 2)
so something like &ptr[2] would be &*(ptr + 2) which would just be ptr + 2

I personally write it as &ptr[2] even if it's redundant, it's just easier to see what I'm doing.
>>
>>59420778
I am jelly as fuck.
>>
Trying to generate random noise.
>>
>>59420848
Well, you've clearly failed spectacularly.
>>
>>59420364
In that case, Lua it is.
Does it work well with multithreading?
>>
>>59420795
monads are a design pattern to compensate for functional programming's weakness
>>
>>59420778
>employed
>Haskell
Must work at facebook behind the scenes right?
>>
>>59420795
linear ordering of dynamic effects
>>
>>59420874
I know.
>>
>>59420882
They're not a design pattern, they're an abstraction over running computations and passing their results to other computations.
>>
>>59420882
>monads are a design pattern
I agree with that. But the rest is like saying "objects are a design pattern to compensate for object oriented programming's weakness".
>>
>>59420922
it's cheating

a purely functional language wouldn't be able to print to the screen or do anything even remotely useful
>>
>>59420879
Depends on what you mean by that. Most people spin up separate instances of the interpreter in each thread and then use coroutines for individual tasks on each processor.

There are plenty of libraries out there for threading with Lua and message passing between threads. I haven't used any of them.
>>
>>59420956
Effects are fine, side effects are not. Monads are one way of "lifting" side effects into first class effects.
>>
>>59420956
please consider:
>MONADS HAVE NOTHING TO DO WITH IO
>MONADS HAVE NOTHING TO DO WITH IO
>MONADS HAVE NOTHING TO DO WITH IO
>MONADS HAVE NOTHING TO DO WITH IO
>MONADS HAVE NOTHING TO DO WITH IO
>>
>>59420956
>or do anything even remotely useful
THAT'S THE IDEAL WE WAITED SO LONG
>>
>>59420977
CPUs make use of side effects
>>
>>59420999
Under the hood it's inevitable, but that's irrelevant.
>>
>>59420999
The point is that the side effects performed are part of the values, they can be altered and inspected (assuming the constructors aren't hidden).

For instance, you could write a console IO type, and then write a function that alters a console IO action and removes any mention of a particular thing from being output.
>>
How do you make a programmable analogue computer?
How do you program it?
>>
Sorry guys I can't get out of a retardation zone, not the op tho
>dereference a pointer
>get a value
>try to get an address of a value
>tfw that makes no sense
&(*(ptr)) --> &67

what am I doing wrong here?
>>
>>59420899
That's a good aphorism.
>>
>>59421029
Why do you need a whole language to enforce this?
You can write code with no hidden side effects in any language.
>>
>>59421057
Of course, but not all languages have the ability to abstract over effects like what e.g. Haskell can do with monads.
>>
>>59421049
You're taking the address of an integer literal.
>>
>>59421057
The difference is that purity makes your language a lot more sensible
You can cleanly (using monads, or other things) embed effects, where you simply describe a main value (which is a description of an effectful program), and the compiler then translates that value into a program
>>
>>59418657

I have discovered some images cause my monitor to make audible noise

It actually sounds higher when it switches between black and white more (as if you zoomed out on this image). This leads me to believe it is actually a sweetspot that causes this noise to be in the audible range. a a random checkerboard bitmap doesn't work.
>>
>>59421072
Oh, and I meant to say, the reverse isn't nearly as nice

Look at const in C++, for instance
>>
>>59420941
its like saying "inversion of control is a design pattern to compensate for object oriented programming's weakness." pretty dumb, right?
>>
>>59421143
No monad are great, inversion of control is stupid.
>>
>>59421049
C has the concept of 'lvalues' and 'rvalues', named after the side of an assignment operator you would typically see it on.
To put it broadly, an lvalue is a variable has storage associated to it, and can be assigned to. An rvalue does not have storage; it's the result of some expression.
When you have an lvalue, and you use the address-of operator on it, you will get a pointer to the storage.
int a = 10;
int *ptr = &a;

In fact, the address-of operator is only defined for lvalues:
int *ptr = &10; // Error. Can't take the address of an rvalue
10 = 11; // Error. Can't assign to an rvalue

It doesn't really make sense to take the address of an integer literal, or something which doesn't have storage (a memory address) associated with it.
From this, we can know that pointers always have to point to an lvalue. So whenever we dereference a pointer, we get an lvalue, and since it's an lvalue, we can take the address of it.
*ptr = 11;
int *ptr2 = &*ptr;
>>
>>59421209
mtl is basically ioc because it lets you supply your own monad
>>
>>59421143
My point is, that there is nothing in monads that make them so special, that they get rid of functional programming's weakness. There are just a nicer way of doing things, but everything they do can be done as well as without them
ignoring Haskells IO
.
>>
>>59421107
>discovered
we've known this for years

http://thume.ca/screentunes/
>>
>>59421049
'&' generates the address of an object
>>
>>59421315
In C++ it's overused. It can mean a dereference or an reference depending on its position relative to the name.
>>
non-ass C/C++ dependency management when
writing CMake modules is tiresome as shit but the alternatives are even worse
>>
>>59421233
>we get an lvalue, and since it's an lvalue, we can take the address of it
we can get it with & however its &*ptr so we get its value and then use & on it.

Were am i wrong?
>>
>>59421342
Welcome to the 21st century where modern languages have package managers to handle dependency automatically.
>>
>>59421350
>its &*ptr so we get its value and then use & on it
Yes, that is what that does.
>>
>>59421371
>Every language needs their own shitty package manager
>Not just using your system's package manager
>>
>>59421386
7.5/10 shitpost point right there
>>
>>59421386
>having to maintain a fuckton of packages for every different manager
no thanks
>>
>>59421386
>need libv3.10
>distro repo is at 3.8
>have to use git manually
How about no?
>>
>>59421378
no,you didnt understand what i say,i mean you say
>we get an lvalue, and since it's an lvalue, we can take the address of it
however its &*ptr so i see that we are getting its address after we get its value.
What * does in C in the most in assembly level ?
>>
>>59421427
>What * does in C in the most in assembly level ?
Your question doesn't really make sense.
>>
while D has pointers it also has ref keyword, which eliminates the usage of * and & indefinitely.

instead of fn(int *arg) you can write fn(ref int arg)
instead of fn(int &param) you just write fn(param)
>>
>>59421472
Who the hell cares?
D is a dead shitlang.
>>
>>59421475
Your reply makes me thing you got really upset. Where is this insecurity coming from?
>>
>>59421427
The asterisk operator tells your variable it is a pointer that uses sizeof(ptr) space in memory. That space will hold the address of another variable when you dereference the pointer.
>>
>>59421485
Over the last few days, people have been posting some "features" of D, trying to showcase it, and all I've seen are retarded design decisions.
I don't understand how anyone can defend or actually use that language. Although, outside of the few hipsters in these threads, I don't believe people actually are.
>>
>>59421519
So you've seen people say they use D and that made you so insecure?
Young minds, so hard to understand
>>
>>59421507
>>59421427
And in your case, it comes to hold the address of the pointer itself.
>>
>>59421554
How does saying "I don't like thing" mean that I'm insecure?
I just honestly think D is dead, and doesn't warrant any discussion.
You may as well bring up COBOL instead. At least there are actually some jobs going for it still.
>>
>>59421598
But it's growing. How is it dead if it's growing?
>>
>>59421598
Why should i bring up COBOL if i want to talk about the ref keyword? Are you dense?
>>
>>59421629
>i want to talk about the ref keyword
Why do you want to talk about the pointless features in some deadlang?
>>
>>59421669
Because it's a programming thread and the topic is relevant? Have you actually lost your ability to reason or are you just pretending to be retarded? Honest question.
>>
>>59421692
>the topic is relevant
D was never relevant.
>>
>>59421692
>>59421629
This is why people hate c toddlers
>>
>>59421701
?
D is a programming language and it's relevant to the thread.
>>
>>59421701
>>59421669
>>59421519
>>59421475
Why don't you take your shitty non constructive post and fuck off to >>>/b/?
>>
>>59421711
You clearly posted with an agenda.
Why the hell are you trying the revive the dead? Face it, it's just not going to fucking happen. D is shit, and everybody realised it was shit, and now they've forgotten and stopped caring about it.
>>
>>59421740
>You clearly posted with an agenda.
What "agenda", you pre teen idiot?
>>
>>59421740
>I don't like it so it's shit waaaah
God I HATE these kids
>>
>current state of /dpt/, lul ur language is shit cuz i dun like it
>>
>>59421754
>>59421761
no u are shilling the language I don't like how dare u?
>>
>>59421740
>Why the hell are you trying the revive the dead?
>>59421746 here.

Do you think bringing up the "ref" keyword in this thread will change anything about the popularity of D? Are you this much dense?
>>
>>59421704
>C
But we were talking about D.
>>
>>59421788
Pretty sure you are just another ass flustered c toddler trying to defend your(!) c in this thread from imaginary shills(!)
>>
>>59421785
kek
>>
>>59421785
Just ignore, 4chan is flooded with underage fuckwits
>>
>>59421386
Language package managers let you sandbox on a per project basis. This is a huge, HUGE benefit over system package managers. Two different projects require incompatible packages? No problem.
>>
>>59421107
shitty monitor
>>
>>59421798
i see ya, cia nigger
>>
>>59421754
>>I don't like it so it's shit waaaah
I don't like it _because_ it's shit. It clearly hasn't been designed well.
I even posted an actual criticism for one of the modules in their standard library a few threads ago: >>59407781
And then there is the whole stupid "lazy evaluation" thing someone was trying to flaunt: >>59395686
>>
>>59421828
Can you start putting up trips so I can filter your nonsense?
>>
>>59421836
Why don't you fuck off to the dlang forum with the other 3 D users?
>>
>>59421842
Now that's edgy
>>
>>59421842
>>59421828
Proof that parents need to beat their children more often
>>
>>59421857
*gives you one dolluh*
>>
File: lmao.jpg (108KB, 1920x1080px) Image search: [Google]
lmao.jpg
108KB, 1920x1080px
>>59421828
>I even posted an actual criticism for one of the modules in their standard library a few threads ago
I'm sorry you call that "actual criticism"?
>>
>>59421828
>waah useful standard library is bad
>>
>>59421828
>lazy evaluation
>"stupid"
What happened to /dpt/?
>>
>>59421598
At least he isn't shilling lisp.
>>
>>59418657

class Entity {
public:
virtual void onTick(void) {}
~Entity() {}
};

class RenderedEntity : public Entity {
public:
virtual void drawSelf(void) {}
virtual glm::vec3 getPosition() {}
private:
glm::vec3 xyz;
};

Should these be merged?
>>
>>59421899
http://boreal.aggydaggy.com/programming/2016/05/26/entity-safari.html
>>
>>59421828
>no business doing in stdlib
Ah I see you are a true programming language scientist.
>>
>>59421871
How is it not criticism? It's not particularly in-depth, but there are actual points being made there.

>>59421886
What was being advertised wasn't lazy evaluation at all: it was a stupid syntactic sugar over a function call.
That's what the whole thing was about.
>>
>>59421233
thank senpai, I think I got it
>>
>>59421909
You are pathetic in so many level
>>
>>59421899
Do all entities need position and ability to be drawn?
If yes, then merge, if not then no.
>>
>>59421909
Hey, just fuck off. Honestly, this is an 18+ site
>>
>>59421907
>>59421883
This stupid "just put everything into the standard library" is what leads to shitty, bloated languages.
Some of those functions there are so fucking niche. balancedParens? Seriously, how fucking often are you going to want to use that? You can't even do anything useful with that.
>>
>>59421935
>"MUUUUUH BLOAT XDDDD"
>>
>>59421927
They don't, it just makes some code in my entity manager neater.
>>
>>59421935
>This stupid "just put everything into the standard library" is
This stupid "just put everything into the standard library" attitude is*
>>
>>59421935
what the fuck is the problem? don't have to use balancedparens? don't fucking use it. idiot
>>
>>59421935
>Rich library is bad
Aww so cute
>>
>Replying to baits
>>
>>59421958
haha I was pretending to be retarded got'em
>>
>>59421949
The more shit filling up the standard library, the harder it is to find the functions that are actually useful.
It makes implementing the standard library harder, and you won't be able to get any alternative implementations of it.

>>59421954
>Rich
Useless*
FTFY
>>
>>59421964
see >>59421932
>>
>>59421935
You can use it to make sure the parens are balanced before tokenizing input when writing math expression parser, how is that not useful?
>>
File: joy of php.jpg (54KB, 400x567px) Image search: [Google]
joy of php.jpg
54KB, 400x567px
The only PHP developers do it because they need the money, like a stripper.
Isn't it weird how this horrible language remains so widely used, given that no one enjoys it?
>>
>>59421967
>Useless
>"Everything I will use for my fizzbuzz is useful and everything else is useless"

FUCKING GET OUT KID
>>
>>59421967
>the harder it is to find the functions that are actually useful.
That list of library is "hard" to look up stuff for?
oh boy
>>
Stop replying to baits
>>
My new online nickname - balancedParens
>>
Does C have a built in hash library or do I need to roll my own?
>>
>>59421972
For starters, how often are you building such a fucking simple arithmetic parser? You can't even change the function in any way to accept any more complicated kind of grammar.
Secondly, you can check the parenthesis at the same time as parsing the input. In fact, you have to. It's just pointless duplicate work.
Third, the function is way too easy to implement yourself. You can scan over the string once with an integer keeping track of how many you've seen, and you're done. It's not that easy to implement functions don't belong in a standard library, but they should only be there because they're so commonly used that it would make no sense to make people implement it themselves. For example, C's strlen: it's fucking trivial to implement, but basically every program wants to use it, so it belongs in the standard library. A program which is BOTH trivial and niche does not belong there.
>>
>>59422012
No. You need to do it yourself.
>>
>>59422028
>A program
A function*
>>
>>59418860
IBM VGA8
>>
>>59422039
>A program
>A function*
A procedure**
>>
>>59422064
No, it returns a value, so it's a function.
>>
>>59422071
Functions are just syntactic sugar for procedures.
>>
>>59422091
Some languages have specific requirement differences between functions and procedures
>>
>>59420305
I know about all the stuff that's wrong with XML, but why is it considered harmful. Because you can use a proprietary DTD or something?
>>
>>59422360
XML attacks can DoS machines
https://en.wikipedia.org/wiki/Billion_laughs
>>
>doing project euler problems in visual studio because I am already using it for other stuff and why not
>maybe I just suck at configuring it but my project folders for these baby programs are 17mb.
>plan on doing 500+ of these problems

wew lad back to the text editor and command line.
>>
>>59418724
>wanting alternatives to Lua

Lua is master race and you sir are a faggot.
>>
>>59422139
Yes, but those that do have functions invariably implement them as macros or subroutines.
>>
>>59422423
IDEs are code-word for bloat.
>>
File: 1488311181113.png (205KB, 1442x455px) Image search: [Google]
1488311181113.png
205KB, 1442x455px
>>59420305
After taking 8 minutes to install rust and compile it, it gives me this.
>>
>>59422495
Heh
>>
>>59422414
Yeah but they're perfectly okay with C...
>>
>things like closures and (co)inductive data types can be implemented efficiently for a systems language simply by turning them into type classes
Really stirs up the old brain juice.
>>
I want to learn Python and PHP (yeah yeah I know, but still want to learn it).
Recommendations for books?
>>
>>59419892
>Think PHP v2 was shitty? Your custom language will be worse to everyone except yourself.

I'm not that big a code monkey.
>>
>>59420340
sauce? That's the cutest anime I've ever seen
>>
>>59420328
static size_t
filter_duplicate (uint8_t xs[*], size_t xs_len);

static size_t
filter_duplicate (xs, xs_len)
size_t xs_len;
uint8_t xs[xs_len];
{


And that's not to mention function pointers restrict, volatile or _Atomic.
>>
>>59422851
Actually it should be
uint8_t xs[static xs_len];
Sorry.
>>
File: 1486014648516.jpg (56KB, 960x620px) Image search: [Google]
1486014648516.jpg
56KB, 960x620px
>>59421033
I... I want to know who this perfect woman is
>>
>>59422708
I don't know about PHP but try automate the boring stuff for Python
>>
>>59422910
Thanks alot man, I appreciate it.
>>
>>59422875
That's not a woman, It's a cartoon you fucking weeb autist.
>>
>Make a very unique never before done web business application for Android
>Register to get the account up so I can upload the program
>$25 for a license fee
>25 bucks

Where were you when Capitalism has ruined free software
>>
File: hmm.png (63KB, 200x211px) Image search: [Google]
hmm.png
63KB, 200x211px
>>59421972
>parsing balanced brackets require context-free parsing
>the language has to offer a fucking stdlib function for that
>just to make sure code monkeys won't use regular expressions

I wonder why languages have regexp literals built into them, but don't even have a good generalized context-free parser library that implements algorithms such as Earley or GLR.

Even their fucking Regexps suck:

https://swtch.com/~rsc/regexp/regexp1.html
>>
>>59422939
>He doesn't have 25 bucks buried in his couch, alone.
Um, Anon?
>>
>>59422935
OK tell me who that cartoon is

I will marry it
>>
>>59422939
Isn't it free to submit your app to amazon app store?
>>
>>59422974
http://www.pixiv.net/member_illust.php?mode=medium&illust_id=16362209

You can marry the author if you want but may be disappointed in the result.
>>
>>59422939
It costs like a billion dollars to sign your package, you're getting a great deal go̶uy.
>>
File: gshit.png (637KB, 1280x720px) Image search: [Google]
gshit.png
637KB, 1280x720px
>>59418989
>>
hol up
function muhFunc1() {
s = 10;
}

function muhFunc2() {
s = s + 1;
}

muhFunc1();
muhFunc2();

console.log(s);


>mfw 11
Javascript variables have global scope by default without using var? What kind of fucked up shit is this
>>
>>59423141
Lua is worse. EVERYTHING is global by default unless EXPLICITLY declared local.
>>
File: stronk.jpg (113KB, 573x892px) Image search: [Google]
stronk.jpg
113KB, 573x892px
>>59423141
>I don't actually know the language but came here to complain about it

>>59423156
Lua is perfect you bitch ass faggot
>>
Do any languages outside of the C/C++ family have undefined behavior? I've read stuff that say basically "undefined behavior is this thing some programming languages have", but I have yet to see any specific examples that aren't from C or C++.
>>
How do you run a Javascript program? I can't seem to figure it out. Do I have to use something like V8?
>>
>>59423141
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/var

This explains the relevant part of the retard javascript parser. Note I said relevant part, it gets worse.
>>
>>59423178
Undefined behavior is only a thing when it comes to autistic ISO standards.

Want an example? Ruby didn't really have any undefined behavior until it was standardized. NOBODY gives a fuck about that standard, except the Japanese governments who love that shit and "require" it in order to actually adopt technology. Nobody actually targets standardized languages because they just aren't very interesting.

The Linux kernel isn't written standard C.

>>59423179
Yes. V8 comes with a debugging shell called d8 you can use to evaluate Javascript. Chrome also has a fully featured one in the developer tools panel.
>>
>>59423179
It's interpreted, so you need a Javascript engine (interpreter). There's one provided in all modern browsers, you can usually access it directly using something like tools menu->developer tools->console, and you can just type or paste in Javascript code and press enter to execute it (basically like an OS shell). Alternatively, you can include the .js file in a HTML file using the <script> tag, and open that in your browser, the script will execute automatically. There's also the option of node.js, which is a standalone JS interpreter which you can run from the command line by specifiying the name of your JS file.
>>
File: youre_a_cooL_kid.jpg (19KB, 277x227px) Image search: [Google]
youre_a_cooL_kid.jpg
19KB, 277x227px
>>59423218
>>59423219
Thanks anons.
>>
>>59423218
Is GNU C truly free of undefined behavior? In other words, does every operation, that does not result in a compile-time error, have a specific, well-defined result?
>>
>>59423254
No, never. You don't even have exact behavior in glibc between platforms.
>>
File: 4k.contentawaresatan.jpg (254KB, 1500x844px) Image search: [Google]
4k.contentawaresatan.jpg
254KB, 1500x844px
>>59423254
>Is GNU C truly free of undefined behavior?

>mfw

>does every operation, that does not result in a compile-time error, have a specific, well-defined result?

The result of undefined behavior is the compiler will often completely ignore the code and/or optimize it away for performance reasons.
>>
>>59423273
>>59423279
Yes that pretty much is what I thought, but >>59423218 seemed to be saying that everything was well defined within a specific implementation.
>>
>>59423279
No, the compiler makes assumptions based on the C standard. It doesn't cause UB, the code shits the bed because it invokes UB.
>>
File: antibully ranger.png (365KB, 512x512px) Image search: [Google]
antibully ranger.png
365KB, 512x512px
>>59423141
Don't bully javascript
>>
>>59423279
>Compiler removes your very efficient check if the value goes negative
>Infinite loop ensues
>mfw
>>
>>59423218
>The Linux kernel isn't written standard C.
Really? What kind of C is it written in?
>>
>>59423325
Not trying to bully here senpai. Just having a hard time digesting all these loosely typed things, that's all. Gonna sleep with ecmascriptstandard.pdf tonight

>>59423205
thanks
>>
>>59423305
It's not well defined, although on a specific platform you can assume what the UB does. e.g. if I overflow the stack, where would that extra data logically go?
>>
>>59423362
C with gcc extensions
>>
>>59423325
Javascript is meant to be bullied, it's the retarded kid normals seem to like.
>>
>>59423393
NEW
>>
File: whichRxORAkka.png (190KB, 1762x684px) Image search: [Google]
whichRxORAkka.png
190KB, 1762x684px
Should I learn Akka or Rx?
>>
>>59423407
No.
>>
>>59423305
I am that guy. The thing is the compiler isn't actually the implementation. The compiler's target is the actual implementation.

C isn't like the interpreted languages where you have a program that runs your code. To these languages, that program is the implementation and it defines everything about the language. It's a virtual computer.

Consider for a moment the undefined nature of C. It is undefined enough that an unholy amount of hardware architectures serve as valid implementations of the language. By saying barely-defined shit like "ints have at least X bits", you can support more implementations than if you said "ints have exactly 32 bits".

And that's the "implementation dependent" stuff. Undefined behavior basically means your entire program is undefined, and the compiler can do whatever it wants, including what you intended to happen.

>>59423362
The version of C with GNU extensions and compiler directives and inline assembly.
>>
>>59420848
post code in a pastebin or github
>>
File: thinkin.jpg (95KB, 458x720px) Image search: [Google]
thinkin.jpg
95KB, 458x720px
>>59423177
I agree that Lua is perfect but it does have a few flaws, namely two. First off, variables being global by default, second, it has no "+=" operator. Of course, any more than this would be bloat as the devs have pointed out, but a += is justified.
>>
File: akari_anti_anti_bully_ranger.jpg (134KB, 762x613px) Image search: [Google]
akari_anti_anti_bully_ranger.jpg
134KB, 762x613px
>>59423325
Bully javascript
>>
>>59420620

sum is a function which takes a list and returns a number. It adds the car of its argument to the sum of its cdr, and returns 0 if the argument given is the empty list.

In

(sum '((sum (hi-fun '(sum product) '())) 2 3 4))


The car of the list is

(sum (hi-fun '(sum product) '()))


which is not a number.
Thread posts: 322
Thread images: 43


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