[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: 27

File: llvm1.jpg (504KB, 580x800px) Image search: [Google]
llvm1.jpg
504KB, 580x800px
Old thread: >>59018426

What are you working on, /g/?
>>
File: 1485473684854.png (408KB, 824x792px) Image search: [Google]
1485473684854.png
408KB, 824x792px
>>59023578
Cute image, OP.
>>
>>59023578
wtf man i want to fuck anime now
>>
C is objectively the best language, now and forever!
People will be writing new C code 50 years from now.
Can you say the same about your shit-tier flavor of the month languages?
>>
perl is very important
>>
Golang is the future
>people stuck in the 80's
ASM -> C -> C++ -> (Java -> Python -> Ruby) -> Javascript
>new and aspiring programmers
ASM -> Rust -> Golang -> Web assembly

Prove me wrong.
Protip: you can't
>>
>>59023614
What are the arrows even supposed to signify?
>>
>>59023610
>40 years back
FORTRAN is objectively the best language, now and forever!
People will be writing new FORTRAN code 50 years from now.
Can you say the same about your shit-tier flavor of the month languages like C?
>>
File: 1452073157348.jpg (104KB, 1052x1342px) Image search: [Google]
1452073157348.jpg
104KB, 1052x1342px
>>
Defend this.

$
$ node -e "console.log(-1 % 7)"
-1
$ echo "-1 % 7 "| bc
-1
$ echo 'package main; import "fmt"; func main() { fmt.Println(-1 % 7) }' > /tmp/glass-test.go
$ go run /tmp/glass-test.go
-1
$ echo -e '#include <iostream>\nint main() { std::cout << -1 % 7 << std::endl; }' > /tmp/glass-test.cpp
$ g++ -o /tmp/glass-test.out /tmp/glass-test.cpp
$ /tmp/glass-test.out
-1
$ ruby -e "puts -1 % 7"
6
$ python -c "print -1 % 7"
6
$ perl -e "print -1 % 7"
6
>>
are these regular expressions equivalent?
A
\'(\\.|[^\n\'\\])*\'

B
\'(\\.|[^\'\\])*\'


i think so
>>
>>59023619
low level -> high level
Get some help:
https://psychcentral.com/quizzes/autism.htm
>>
>>59023578
>LLVM
enmey of freedom
>>
>>59023656
why tho
>>
>>59023656
>not using libFirm instead
freedom! ~
>>
>>59023628
>false allegory fallacy

Just stop
>>
>>59023640
It depends on the regex implementation and their treatment of newlines.
>>
>>59023640
Are you still at this? The bottom one is clearly omitting the newline character and will give different results with certain text, namely it'll match two single quotes on separate lines
>>
>>59023628
>40 YEARS BACK.
FORTRAN IS OBJECTIVELY THE BEST LANGUAGE, NOW AND FOREVER!. PEOPLE WILL BE WRITING NEW FORTRAN CODE 50 YEARS FROM NOW. CAN YOU SAY THE SAME ABOUT YOUR SHIT-TIER FLAVOR OF THE MONTH LANGUAGES LIKE C?.
>>
>>59023630
> https://en.wikipedia.org/wiki/Modulo_operation

> When either a or n is negative, the naive definition breaks down and programming languages differ in how these values are defined.

this is undefined behavior as far as the definition of the operator is concerned, so anything goes

fucking noob
>>
POST YOUR FUCKING PROJECT RIGHT FUCKING NOW
>>
>>59023773
I'm currently contemplating the design of a programming language, and what issues it might have.
>>
>>59023630
i can't defend this
from my experience 6 is more practical, though
>>
File: point_at_laptop_stallman.jpg (783KB, 2272x1704px) Image search: [Google]
point_at_laptop_stallman.jpg
783KB, 2272x1704px
>>59023653
>WebAssembly
>high level

WebAssembly is a specification for an AST as a compilation target. It isn't even a language anymore you knob.
>>
File: 1407803991171.png (380KB, 600x664px) Image search: [Google]
1407803991171.png
380KB, 600x664px
>/dpt/ is now the containment thread for shitposts
>>
>>59023804
>implying it hasn't always been
>>
>>59023762
>this is undefined behavior as far as the definition of the operator is concerned
No it's not.

>>59023630
'6' is 'true' mathematical definition of modulo base 7.
-1 is the "quotient * denominator +remainder = numerator" approach.
>>
>>59023728
so the bottom one can't match the \n character?

but
\'\\.\'


matches '\n'

the dot matches anything except line breaks
>>
>>59023804
>now
>>
>>59023818
>'6' is 'true' mathematical definition of modulo base 7.
hahahahahahahahahahahahahahahahaha
>>
File: 1487549208628.png (95KB, 600x664px) Image search: [Google]
1487549208628.png
95KB, 600x664px
>>59023804
your png is now optimized
>>
>>59023604
Go to an anime convention, fuck a cosplayer.

>>59023628
Fortran is, in fact, still in use for a few scientific applications.

>>59023818
>No it's not.
Yes it is. And stop pretending that everything that goes on in a programming language has to follow the conventions used by mathematicians.
>>
>>59023859
Do you not even know modular arithmetic?
Get out of here, non-CS scum.
>>
>>59023876
what tool did you use? is optipng still the best?
>>
>>59023827
The bottom one *can* match the \n character.

[^\'\\]


The caret ^ negates the character set. The portion of the regex above says "match everything that's not a single quote or a backslash".
>>
>>59023876
your optimization is not lossless
kys
>>
>>59023904
how to know if something was compressed lossless or lossy?
>>
>>59023920
Without even needing tools, you can just open both images in two tabs and go back and forth between them.
It's extremely obvious that your compressions fucked up her bow.
>>
>>59023893
i'm math scum lolololololol
you'll find different conventions in different papers, although i'll agree that the one using 6 is more common
it's far from being commonly accepted, though
>>
>>59023818
>'6' is 'true' mathematical definition of modulo base 7.
No it's not.
>>
>>59023728
What's this add-on for vertical tabs ?
>>
\n or endl?
>>
>>59023944
>>59023943
>>59023892
Oh, we used the negative wrap around thing at my university.
I was not aware that there were different conventions to this. Maybe the lecturer mentioned that, but I don't really remember.
>>
>>59023951
\r\n
>>
>>59023946
Tree style tabs.

>>59023951
std::endl for impromptu debugging, \n the rest of the time.
>>
File: d.png (300KB, 600x664px) Image search: [Google]
d.png
300KB, 600x664px
>>59023904
here autist
>>
>>59023951
Not using C++ is the option I choose.
>>
>>59023946

That is tree style tabs. You can only get it for Firefox, and once you start using it, you won't be able to stand any other environment again. It is just the only appropriate way to manage 20-50 or more tabs.
>>
>>59023973
\n -> unix
\r -> mac
\r\n -> windows
>>
File: 1472390390693.jpg (47KB, 750x750px) Image search: [Google]
1472390390693.jpg
47KB, 750x750px
Hi, not sure if /sqt/ may be better, but I guess you guys can awnser this better: How are compilers compiled? Can I compile GCC somehow? If so, how to compile the compiler that compiles the compiler?
>>
>>59023972
you'll find inconsistencies like these everywhere
like those linear algebra heathens often resorting to using the strict subset operator for regular subsets
>>
are you fucking kidding me
>>
>>59023981
anon bls
i'm colorblind and even i can tell the difference between the colors
>>
ffs /g/ just tell me what the best programming language is
>>
>>59024034
perl
>>
>>59024034
Rust
>>
>>59024006
Search for "chicken egg compiler".
>>
>>59024034
one that pays well I should add aswell
>>
>>59024034
VBScript
>>
>>59024034
lisp, scheme
>>
>>59024034
C
>>
>>59024028
there is no difference between the colors, because i used a lossless compressor

kys retard
>>
>>59024016
only pajeets worry about algorithms
>>
>>59023804
/g/ has really gone to shit in the last 8 months. Too much consumer bullshit
>>
>>59024006
how are machines built? can i build machines somehow? if so, how to build the machine that builds the building machine?

tl;dr: universal turing machine, gödel numbering
>>
>>59024034
C, although good luck finding a job to work with it.
>>
>>59024034
Rust
>>
File: 1457085233960.jpg (28KB, 450x282px) Image search: [Google]
1457085233960.jpg
28KB, 450x282px
>>59024055
bloat, just use batch
>>
>>59024006

First compiler written in a language other than the language that compiler compiles.

Next compiler written in the language compiled by that compiler. Previous compiler used to compile new compiler.

Subsequent compilers compiled with previous versions of compiler written in the same language they are designed to compile.

We call this compiler bootstrapping.
>>
>>59024034
rust!
>>
>>59024067
>in the last 8 months
It has always been like this.
>>
File: Vr_Viewer.jpg (514KB, 1375x894px) Image search: [Google]
Vr_Viewer.jpg
514KB, 1375x894px
>>59023578

A GUI to organize all my VR and regular porn videos with one button streaming to my Google Cardboard headset written in PyQT5.

I'm thinking of switching the video info and the 4 thumbnail section. Thoughts? Are there any UI mockup sites to get inspiration from?
>>
>>59024095
who gives mail to the mailman?
>>
>>59024100
>le <insert 4chan board here> has never good
>>
>>59024104
>CHAD WHITE
>>
>>59024112
>has never good
pajeet pls go
>>
>>59024104
>VR
you can't feel anything. what's the point?
>>
>>59024086

>Batch
Garbage. Use Powershell.
>>
>>59024125
Excuse me, Sir?
>>
>>59024065
you're right
chromium shows it in different shades, but downloading both files proves that it's the same
>>
>>59024140
>Powershell
Garbage. Use sh.
>>
File: S 2017-02-20 at 01.28.38.png (34KB, 123x129px) Image search: [Google]
S 2017-02-20 at 01.28.38.png
34KB, 123x129px
>>59023578
What's the simplest way of implementing event delegation in JS? Use jQuery?
>>
>>59024174
>JS
do you not see the amount of pleb blood shed ITT? Not even C babbies are safe here
>>
>>59024174
use angularjs 3
>>
>>59024158
>Garbage
Garbage. Use garbage man.
>>
>>59024174
example
var ul = document.getElementById('items');

function addEvent(obj, evt, fn, capture) {
if ( window.attachEvent ) {
obj.attachEvent("on" + evt, fn);
}
else {
if ( !capture ) capture = false; // capture
obj.addEventListener(evt, fn, capture)
}
}

addEvent(ul, "click", function(e) {
var target = e ? e.target : window.event.srcElement;
if ( target.nodeName.toLowerCase() === 'a' ) {
alert("clicked");
return false;
}
});
>>
>>59024214
Never reply to me again unless you're contributing to the thread.
>>
>>59024108

Pretty sure some mailmen deliver their own mail.

>>59024158

Not all Windows environments have sh installed.
>>
>>59024034
INTERCAL
>>
>>59024227
not all windows environments have powershell installed either
>>
>>59024227
>Windows environments
Get out of here, ponyfag reddit-spacer.
>>
>>59024269
>Get out of here, ponyfag reddit-spacer.
Get out of here, ponyfag reddit-spacer.
>>
reminder that ruby spent a lot of money on pony plushies
>>
>>59024187
>shitting on JS
can't wait to hear about your to-do list app written in Swift.
>>
>>59024292
at least he has money, poorfag redditor
>>
>>59024293
can't wait to hear about your to-do list app written in <flavor of the month js frontend framework>.

THE TO-DO LIST MEME ORIGINATED IN JS!!!
>>
>>59024307
>he
did you just?
>>
>>59024307
:-(
>>
>>59024307
>he
r-rude
>>
>>59024307
>he
pls don't bully
>>
>>59024314
>>59024335
>>59024338
>tfw you realize you will never be a cute loli
>>
>>59024335
Get raped and kill yourself, you retarded fucking faggot sack of nigger shit with down syndrome.
>>
>>59024355
PEDO GO HOME
>>
>>59024361
why do you post the same reply over and over again?
>>
>>59024362
we don't forget
we don't forgive
we have over 9000 penises and they are all raping children.
>>
>>59024361
P L S D O N T B U L L Y
>>
>>59024380
>le ebin oldfig meymeys
>>
>>59024362
Wanting to be a little girl is not the same as wanting to fuck a little girl.

You have a very perverted mind.
>>
>>59024396
What's wrong, too sjw to handle lolis?
>>
>>59024256

Every Windows machine since Vista comes with Powershell pre-installed by default. By comparison, Bash must be installed third party.

>>59024292

That's nothing. Back in 2009, I saved up 2 grand on a Macbook Pro. 2 years later, I learned the hard lesson that Apple cannot into hardware. I hear these days, they still suck at managing heat.

>>59024314
>>59024335
>>59024338

I have repeatedly stated in these threads that I am male. "He" is the only correct pronoun to use, unless you literally don't know what gender I am (note: on 4chan, assume male unless proven otherwise), in which case, "they" is technically grammatically correct (but it'll sound weird).
>>
>>59024420
SO MANY YOU'S IN ONE POST
MOM GET THE CAMERA
>>
>>59024420
>That's nothing. Back in 2009, I saved up 2 grand on a Macbook Pro.
so what do you use now?

and how's the Washington weather?
>>
>>59024420
put your pronouns in your name so no one makes the same mistake
>>
>>59024420
"""male"""
>>
>>59024420
>third party
Not any more.
>>
>>59024458
Windows 10 isn't the only Windows still in use.
>>
>>59023986
>>59023974
Thanks senpai, yea I do lots of research so I end up with lots of tabs usually thanks!
>>
>>59024479
Yeah you're right, XP is still in use. It doesn't come with PowerShell
>>
File: yui does the cute thing.gif (802KB, 500x545px) Image search: [Google]
yui does the cute thing.gif
802KB, 500x545px
How do you feel about using the comma operator to concatenate multiple statements together instead of using braces in your if/else constructs?
>>
File: file.png (23KB, 418x369px) Image search: [Google]
file.png
23KB, 418x369px
>>59024420
>By comparison, Bash must be installed third party.
It's literally just another windows feature now.
>>
>>59024511
In which language?
>>
>>59024511
shit tier
braces for if blocks are nice because they resemble the mathematical syntax for case differentiation
>>
>>59024404

In some cases it is, actually. In one commonly accepted (although heavily criticized) scientific theory, there are two types of trans women: those who are androphilic (HSTS) and who typically experience the desire to transition early in life, and those who are gynephilic (AGP), who typically experience the desire to transition later in life. For the former, the cause is neurological. Simply put, the individual has a similar neuron count and neural density to biological women. For the latter, the cause is what is known as an erotic target location error. These individuals are attracted to the idea of themselves as the subject of their attraction.

>>59024442

Right now I use a System76 Kudu laptop, which runs Ubuntu.

>>59024458

It is still not installed out of the box, whereas Powershell is an okay shell language that is installed on every Windows machine since Vista. Also installed on most Windows machines out of the box is a C# compiler, although it is hidden outside of the PATH environmental variable.
>>
>>59024511
The comma operator should only be used in VERY specific situations, where a normal statement cannot be used.
>>
File: 1456007784488.gif (18KB, 340x340px) Image search: [Google]
1456007784488.gif
18KB, 340x340px
>>59024479
>He uses a deprecated version of Windows
>He uses Windows at all
>>
Alright listen up, I want one of you motherfuckers to tell me what is THE god tier programming language and you better not answer Java or some other poo tier shit
>>
>>59024574
Rust
>>
>>59024574
perl
>>
>>59024557
>trying to justify your sexual perversions with that shit
Lay off the internet for a while
>>
>>59024536
Probably C, that's the most well known language with that feature. Though apparently it also works in JS (with statements, but not functions). It's an obscure feature in any case.
>>
>>59024574
rust.
>>
how do delete rust
erase history
>>
>>59024557
Interjecting for a moment about transgender theory isn't really helping to convince people that you're not a tranny.
>>
>>59024584
In C it's tricky because it's not a sequence point.

a += 5, b = a


Is undefined behavior, even if there's no UB I would recommend against it as a a style choice.
>>
>>59024604
you can delete certain keywords from a thread

you have to put in the name field

::delete("your word here")
>>
>>59024574
Rust is the closest to perfection
>>
>>59024629
no delete keyword
delete rust from history
>>
>>59024617
No it's not UB. Ugly and dumb but not UB.
>>
>>59024617
>because it's not a sequence point
Actually, I'm pretty sure it IS a sequence point.
I'm going to look that up.
>>
>>59024617
This is well defined.
The comma operator, when not being used as a separator, is it's own operator and this would result in a being incremented by 5 before being assigned to b.
In a comma chain, all values are discarded but the last one, so it's only useful to cram in side-effects and generally be an asshole.
>>
>>59024639
You can clear history in your browser easily
>>
>>59024583

I suggest you get your eyes checked. I never claimed I was trans in any way. I merely stated that autogynephilia is a thing.

>>59024610

If I was a trans woman, why would I complain about /dpt/ referring to me as a "she"?
>>
>>59024610
I concur.
>>
>>59024647
>>59024617
http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf
Yes.
>6.5.17
>The left operand of a comma operator is evaluated as a void expression; there is a sequence point between its evaluation and that of the right operand. Then the right operand is evaluated; the result has its type and value.
>>
>>59024639
this board is for english speakers only
>>
>>59024656
no
delete rust from man history

>>59024668
yankee leave
>>
>>59024678
>man history
botnet, once logged, you cannot remove it
>>
>>59024698
pls help remove rust
>>
>>59024657
>If I was a trans woman, why would I complain about /dpt/ referring to me as a "she"?
Because you don't currently identify as a woman. Maybe you questioned your gender in the past, and decided that living as a woman wasn't worth the trouble.
>>
>>59024703
>issue: WONTFIX
>>
File: product-rust.png (100KB, 251x452px) Image search: [Google]
product-rust.png
100KB, 251x452px
>>59024703
>>
>>59024709
pls

>>59024712
thank
>>
>>59024707

Never have I questioned my gender, never can I conceive of myself questioning it in the future.

>>59024703

Why remove Rust?
>>
>>59024712
As for the language, just ignore it and the users.

It will fade and disappear like the rest.
>>
>>59024731
>Why remove Rust?
Too hard
>>
>>59024731
>Why remove Rust?
It degrades the strength of iron.
>>
>>59024752
>strength of iron.
no such things as that
>>
>>59024731
help rust remove?
>>
>>59024758
Ok, I'm not expert on materials, but I do know that letting iron rust is not good for it.
>>
>>59024712
>Targets the rust, safe for surrounding areas
Thank you based WD-40
>>
>>59024776
How do we apply it to /dpt/?
>>
What's the point of C again?
>>
>>59024803
Drink it
>>
>>59024811
Making rust programmers so mad they make shitty blog posts about how much they hate it.
>>
>>59023981
Saving this, you can't stop me.
>>
>>59024811
Not much.
/g/ consists of newbie programmers and a lot of them use C, they hate difficult languages and so they are butthurt about it.

There are not many real world use of C.
>>
>>59024873
>There are not many real world use of C
Are you serious, pajeet?
That's a pretty fucking stupid thing to say.
>>
>>59024853
So point of C is trolling people?
I guess this is why /g/ likes it
>>
>>59024853
That sounds about right, I don't think anyone else expected it was for legitimate programming anymore either.
>>
>>59024873
>There are not many real world use of C.
what
>>
>>59024883
>>59024892
Prove me wrong :)
>>
>>59024898
See: everything
>>
>>59024811
Every time I read stuff like this, I imagine the person who wrote it is a limp-wristed effeminate numale webdev who has never touched a line of compiled code in his life and uses words like "diversity" and "safe space" in the same sentence.
>>
>>59024907
Majority of the codes that I am using is either C++ or Javascript/python. If you are on windows, C++/C# is probably the most used language in your system.

C?
Mostly Kernel
>>
>>59024920
:thumbsup:
>>
>>59023614
I can't understand your shit formatting but Golang is some major ass
>>59023780
go on...
>>59024003
that's only old versions of Mac, OS X is Unix
>>59024104
>more focus on the fucking credits than the actual porn
are you sure you're not gay honey?
>>59024559
there is no place where a comma operator is literally required
>>59024920
>talks about type checking
>never touched compiled code
>>
>>59024920
haha, why are you getting so angry?
>>
>>59024923
Yeah the kernel, also every network service, command line utility, library your using in your language, the CLR for C#, the interpreter for JavaScript and python.

Also a hundred billion other things, but no you're right. Nothing is written in C.
>>
>>59024920
That's good, it saves you from having to consider his argument on technical merits and instead allows you to dismiss them out of hand based on your fleeting emotional state and personal feelings, which is how all stoic and right-thinking men of technology should face a reasoned discussion.
>>
>>59024943
>there is no place where a comma operator is literally required
Sure, but that can be said about more mundane things. If statements are not REQUIRED.
Really though, I can think of 2 suitable situations to use it.
for loops:
for (;; ++a, ++b)

When you want to use side effects in a boolean context:
for (struct list *iter = head; *iter && (ptr = iter->data, 1); iter = iter->next)


The second one seems contrived, but I have used the second example for convenience macros before.
>>
>>59024992
foreach macros?
>>
>>59024976
:thumbsdown:
>>
>>59025007
Yes.
>>
>>59024957
>CLR for C#,
Goes to show no people wants to deal/work with that obsolete trash called C. So is for TCP/IP stack (which is mainly inside the kernel).

If C was so good people would not have to create an interpreter or CLR or JVM.
Deal with it:
C is living on it's borrowed time, it's just there because kernels are ready written
>>
>>59024811
>C is not memory-safe
Computers by nature aren't memory safe, unless we can implement garbage collection in hardware, which is still not practical for general-purpose computers. C isn't the ideal language for high-level applications development, it only caught on for that because of Unix favoring a "quick and dirty" approach rather than user programs planned out well in advance, and in the early PC days anything more abstract than C would have an unacceptable performance penalty. These days you should use something like Java or C++ for high-level applications, and save C for operating systems and embedded systems, where its lack of "safety" is actually a virtue.
>C cannot be garbage-collected efficiently
Again, the answer is that C isn't the right choice for a program design that depends on garbage collection. Either manage memory yourself, or switch to a higher level language. C's specialty is the situations where garbage collection is either unavailable, or would impose an unacceptable penalty.

>C has poor support for dynamic data structures
It does have structs, which make it easy to implement any form of graph data structure. And something like a C++ std::vector isn't too hard to implement either, but if you want the compiler to do all the work for you, that's what C++ is for. The cost of course is a much heavier library.

>C is weakly typed
Again, this is one of the features that assists in writing low-level code, because "types" in machine code are really just a programmer level abstraction, they don't actually exist inside a program. For example, Carmack's fast inverse square route function depended on treating the same values alternatively as both integers and floats, that sort of thing just isn't possible in a language with strong type constraints.
>>
>>59024943
>there is no place where a comma operator is literally required
else
return (ret = (!a) ? NULL : ret), ret;
>>
>>59024957

>the CLR for C#
Actually, that is written in C++ desu.

https://github.com/dotnet/coreclr
>>
File: scala-fs-2012-14-728.jpg (87KB, 728x546px) Image search: [Google]
scala-fs-2012-14-728.jpg
87KB, 728x546px
>>59024574
this >>59024579
or Scala
>>
>>59025019
Yeah sure, just keep waiting. Surely it will all be in javascript by the end of the year.

Also I didn't mean the TCP/IP stack, I meant things like nginx, bind, ntp, ssh, that stuffs.
>>
>>59025056
https://www.youtube.com/watch?v=uiJycy6dFSQ
>>
>>59025031
retard
>>
>>59025024
>Computers by nature aren't memory safe
what do you mean?
C
uint8_t* pointer = (uint8_t*) malloc(SIZE); // Might return NULL
for(int i = 0 ; i < SIZE ; ++i) {
pointer[i] = i; // Might cause a Segmentation Fault
}

rust
let my_var: u32 = 42;
let my_ref: &u32 = &my_var; // <-- This is a reference. References ALWAYS point to valid data!
let my_var2 = *my_ref; // <-- An example for a Dereference.

C
uint8_t* get_dangling_pointer(void) {
uint8_t array[4] = {0};
return &array[0];
}

// Returns a dangling pointer to a previously stack allocated memory


rust
fn get_dangling_pointer() -> &u8 {
let array = [0; 4];
&array[0]
}

// main.rs:1:30: 1:33 error: missing lifetime specifier [E0106]
// main.rs:1 fn get_dangling_pointer() -> &u8 {
// ^~~

C
void print_out_of_bounds(void) {
uint8_t array[4] = {0};
printf("%u\r\n", array[4]);
}

// prints memory that's outside `array` (on the stack)


Rust
fn print_panics() {
let array = [0; 4];
println!("{}", array[4]);
}

// thread '<main>' panicked at 'index out of bounds: the len is 4 but the index is 4', main.rs:3


C is a relic
>>
>>59025024
>Again, this is one of the features that assists in writing low-level code

Most C code, even in drivers and OS kernels, isn't low level to the point of being uniformly typeless bitflipping, and having lax coercion rules in effect through your entire codebase isn't a feature versus just saying what you mean when you need to cast something, as you would in most other compiled languages.

>Carmack's fast inverse square route

Carmack didn't write that.
>>
>>59025024
C fucking sucks, use another language you cunt. Enjoy your buffer overflows.
>>
>>59024811
>C is difficult to optimize
C arose in a time before large-scale parallelization was a thing, in those days efficient code generation meant having programs that were easy to translate to machine instructions in a simple way. Obviously a different type of semantics are needed to create a language that's easy to parallelize, but to the best of my knowledge none of the mainstream "C killer" languages have really focused on that area; the lack of memory safety (which again is fundamental to C's usage, and is only a "problem" when you try to use C as a high-level applications language) seems to be the main criticism people focus on.

>>59024873
C is what most people would consider a "difficult" language, as it lacks garbage collection and automatic variable initialization, has a very rudimentary core functionality (no ability to assign to string variables for instance) and a lot of things depend on pointers.

C is extensively used in writing operating systems and software for embedded systems; there, the things higher-level programming languages depend on are either nonexistent or too inefficient for practical use.

>>59025019
Kernels still need to keep being updated, and that's what C is best at anyways. You shouldn't be using it to write your fancy GUI webapps, but if all C programmers were to suddenly disappear it would only be a matter of time before we find ourselves using outdated operating systems and drivers.
>>
>>59025024
>Every single C project
>Starts of with pure ANSI C
>Project goes larger
>Starts adding OOP features
>Hacks together a poor and unmaintainable program with horrible codebase

Get a job
>>
>>59025101
>C is what most people would consider a "difficult" language
C is a beginners' language
>>
>>59025080
>Might return NULL
Error check then, you fucking idiot. In rust, you can't even check for these things.
You have no choice but to crash.
>Returns a dangling pointer to a previously stack allocated memory
Using that pointer is UB, and a compiler will complain about this.
>prints memory that's outside `array` (on the stack)
UB
>>
>>59025122
> In rust, you can't even check for these things.
How about actually studying a language before posting bullcrap?
>>
>>59025080
>thread <main> panicked
Why didn't that get caught at compile time?
>>
>>59025080
You copied this verbatim from a webdev numale blog.
I can't tell if you're being sincere or not, but here's that (You).
>>
>>59025080
Oh, one more thing Rust eliminates chances of data race
>>
>tfw /dpt/ discord needs a coup RIGHT NOW
OVERTHROW THE PATRIARCHY THAT IS THE ADMIN KING NIGGER
>>
>>59025140
spottted the C numale hipster. Was Fortran too mainstream for you?
>>
>>59025145
>/dpt/ discord
Is this a thing?
>>
>>59025145
>discord
What the fuck is this shit people keep shilling here?
>>
>>59025145
Don't bring that shit in here, it only leads to shitposting
>>
>>59025151
it's a place exclusively dedicated to osgtp shitposting and ruby bullying
>>
>>59025138
Because it wasn't panicking at compile time.
>>
>>59025080
Rust is just doing implicitly what C code has to do explicitly. It supposedly does this all with "zero runtime cost", by doing all the checks at compile time - but that doesn't provide any protection from runtime failures (like a failure of the heap allocator), and it's nothing that a static code analyzer (which has existed for C for ages) can't do. Basically Rust seems to be forcing the programmer to not be an idiot, because apparently many of them are too stupid to figure that out on their own.

>>59025087
What operating system do you use? There's a very good chance that it was written in C. Blaming C for buffer overflows is like blaming a screwdriver for its inability to slice sausage.
>>
>>59025164
Can't the compiler see that it's out of bounds?
>>
I will admit Rust has some restrictions (mostly because it's only couple of years old). But I would never go back to C++ unless my job requires me to.

About C, I don't use C anyways. C++ is superior to C in most aspects
>>
File: 1469109737068.gif (1009KB, 480x270px) Image search: [Google]
1469109737068.gif
1009KB, 480x270px
>>59025080
I read that same blog post as you, and all I saw were stupid day 1 rookie C mistakes.

Also, you can tell he's not a seasoned developer because he just assumes nobody would ever want to pass a stack pointer, or use a negative number as an index.
>>
>>59025194
>C++ is superior to C in most aspects
What?
>>
>>59025030
this code can be refactored. C does not rely on the , operator for Turing completeness
>>59025024
Lisp machines had hardware GC ;°}
>>59025151
'no'
>>
>>59025201
Not joking. Once your project becomes large, you would rather quite than working with C.

C++ makes it a bit easier to implement complex algorithms
>>
>>59025196
In a large production, you will be surprised what silly bugs we find.
>>
>>59025182
>C lets you be an idiot
Is that a good thing?
>>
>>59025212
>C++ makes it a bit easier to implement complex algorithms
Why?
>>
>>59025212
I see tons of huge codebases written in C on my system, people seem to keep working on it even after a decade.
>>
>>59025232
OOP
>>
>>59025246
OOP is absolute garbage.
Don't try to bring that up in an argument against anything.
>>
>>59025252
By now I already know you never got hired because you are just a shitty programmer with high opinions
>>
File: super suction chaika.jpg (117KB, 560x560px) Image search: [Google]
super suction chaika.jpg
117KB, 560x560px
When I first came to /g/, I didn't know how to program, yet I regularly stirred up arguments on programming languages I knew nothing about and I would still get tons of angry replies.
>>
>>59025246
could've brought up templates
nope, oop
>>
>>59025231
I think so, in some sense.

Normals get out: the language
>>
>>59025263
Templates are not any less important, but OOP is just such a pragmatic approach once you understand how to work with it
>>
>>59025267
C:
>I don't care if you are an idiot, just use me pls

Rust:
>Git gud or fuck off
>>
>>59025273
>OOP is just such a pragmatic approach once you understand how to work with it
No. OOP leads to terrible, terrible design decisions, and makes your program extremely difficult to reason about, due to all of the mutable shared state spread out all over the place.
>>
>>59025120
It shouldn't be, having to use pointers for basic I/O is needlessly confusing for beginning programmers. Something like Python is better, you should learn about sequential execution, conditional logic, and functions without having to worry about pointers or classes until later on.

>>59025164
So Rust can't do compile-time bounds checking?
>>
>>59025273
which benefits does it yield pragmatically?
pretty sure you're in your "i can model the real world with oop!" or "look mom, i can implement subject-verb-object in code!" stage.
>>
>>59025231
Yes. Everyone on /g/ who uses C is a totally hardcore seasoned greybeard unix hacker who never has runtime bugs, and if someone else's C code succumbs to a heap spray attack while running on your computer it means they just weren't badass enough, but that's what makes it exciting.
>>
>>59025295
Name one (ONE) complex application that uses procedural programming and avoids OOP
I'll wait
>>
>>59024174
>>>/wdg
>>
>>59025304
see >>59025307
>>
>>59025231
It's more that it shouldn't be the compiler's job to do that stuff for you. With static code analyzers, most of those C memory issues can be avoided, Rust basically just packages it with the compiler.
>>
>>59025307
before we further discuss this issue we need to understand what you call "OOP"
there have been at least a billion missunderstandings before in this regard
>>
>>59025307
>(ONE)
What?
>OOP
First, I'm going to need your special snowflake definition of OOP.
Structs and functions that work on those structs are not OOP.
>>
>>59025182
The reliability comes at the cost of cognitive load and ultimately, development time. In C you need to be merely careful. In rust you're forced to be careful by being forced into awkward rules of reference ownership.

The "fast as C" is a bit dishonest. While the literal rust code compiles to native code with low cost, you still need to write the code in far more awkward style of state sharing, and that style is carried into the machine code output too.

In C you just write it the way you understand CPU likes. In rust, there's simply not the option. Shared data cacheline? Nonsense! Let's spam this shit all around the place, copy-by-value because uh, rules. Which from the CPU perspective make very little sense, it's just to ensure there are no data hazards.

At least other nanny languages do the nannying behind the scenes (ie high level and JIT) and automatically, or through powerful abstractions (ML). In either case, you don't need to spell everything out according to arbitrary awkward discipline.

I can see how some OCD types may find certain appeal in this, but there are far more elegant systems of restricting shared state, if you're so inclined - ie ML and haskall in particular.
>>
>>59025317
a question doesn't answer a question, silly
>>
>>59025321
Yes true, and rustc does that while GCC or llvm doesn't
>>
>>59025289
>just use me pls
That is definitely rust.

Or is there another reason every /dpt/ starts off with somebody shitting on C, C++ and Go while shilling rust without ever written more than 20 lines of it?
>>
>>59025328
>Structs and functions that work on those structs are not OOP.
Point to me where I said that?
>>
i did an interview test in hackerrank. pretty easy questions and all test cases passed but i have my doubts. how hackerrank works really?
>>
>>59025357
same can be said about C
>>
>>59025321
Rust has an elaborate type system that supports static analysis beyond what C is capable of; it isn't merely packaging existing tools in with the compiler. It does compile-time checks C isn't able to with any level of tooling.
>>
>>59025361
You didn't. It's just a common thing that a lot of idiots seem to think, so I was getting it out of the way first.
>>
>>59025364
What was your score?
Post the test, I wanna try.
>>
>>59025366
Except those languages already have a userbase beyond reddit.
>>
>>59025260
You and everyone else.
>>
>>59025369
And yet it apparently still can't do bounds-checking of arrays at compile time.
>>
>>59025306
this seems to be the case

>Rust forces people to write good code
>C allows buggy code
"hurr durr if you are a good programmer you will never write a buggy code" - /g/

Pretty funny
>>
>>59025390
What languages actually do this?
>>
>>59025409
let me introduce you to our lord and savior: DEPENDENT TYPESSSSSSSSSSSSSSSSSSSSSSSSSS
>>
>>59025392
>Rust forces people to write good code
If you call that hideous mess of a language "good code", I'll take your word for it.
>>
>>59025392
If you're a disciplined programmer, you will easy avoid the common types of memory errors in C.
>>
>>59025430
babyduck or stockholm?
>>
File: 16233323847_46e73a5111_z.jpg (128KB, 640x640px) Image search: [Google]
16233323847_46e73a5111_z.jpg
128KB, 640x640px
I took my first two intro programming classes in Java, they covered OOP and linked lists/stacks/queues. I then took a Data Structures class, which didn't really introduce me to anything new, but we had to use C++.
Given that background, could you guys recommend me a decent C++ book. Something that isn't going to spend so much time on:
>this is an if
>this is modulo division
but more about how to use pointers to make linked lists, how to use templates. Also, I don't really understand/remember the difference between const in different positions in the method signature, for example this has const in two places:
const Object &Deque<Object>::getFront() const

and the meaning of the & outside of the parameter, I have no idea what that shit is.
>>
>>59025433
>if you are a good goal keeper you will never let your opponent score a goal
>if you are good at chess, you will never lose a game
>mfw these kids are white knighting in /g/
>>
>tfw the rust community is singing praises for what Ada and spark have been doing for two decades
>>
>>59025433
bugs happen, NEET
>>
>>59025418
Not even dependently-typed languages are able to enforce that at compile time.
>>
>>59025453
>community
stopped reading right here.
>>
>>59025449
You're not competing against the language/compiler, anon.
Your analogies are terrible.

>>59025454
Yes, and?
You should still test your code and whatnot.
>>
>>59025369
>Rust has an elaborate type system

By standards of type oriented languages, Rust is this comic C++ retard trying to act like them.

It's a forced marriage simply so wrong on many levels. C is fine, C++ is horribly broken, but you can't fix it by making it rape ML, and calling the sorry bastard a victory.
>>
>>59025437
Shit is fucking disgusting.

>hurr you just don't get it
>muh semantics
The syntax is butt ugly, borders on perl or PHP.
>>
>>59025455
My toy language can though lmao
>>
>>59025478
>Lying in the internet
>>
>>59025488
yup, babyduck

>>59025479
>test it means the program is bug free
Are you this much new
>>
>>59025445
If you know a language already, you don't need a data structures book that spells it out for you in a specific language.

Just learn all the simple ones, because those are used as primitives for larger and more complex data structures.
>>
>>59025453
And yet you don't hear any of them shilling ada every 5 seconds.
>>
I think participating too much in this thread will give people autism
>>
>>59025501
>Are you this much new
I never claimed that. Fine, formally prove your programs to be correct, then.
>>
>>59025433
No one wants their computer taken over just because some fumbling neckbeard introduced an attack surface because xe had to validate xirself on the Internet using obsolete 70s technology.
>>
>>59025495
why would I be lying about that?
>>
>>59025507
That's probably because two decades is longer than most of them have been alive.
>>
File: 1467098844821.png (51KB, 1306x504px) Image search: [Google]
1467098844821.png
51KB, 1306x504px
>>59025510
Testing products for thousands of paid hours will NOT guarantee that you have missed

Maybe you can test your fizzbuzz thoroughly, but not in real life programs. Picture related got 1.2 billion hours of testing
>>
>>59025509
We were autistic before we came here. It's just that so many autists gathered in the same place that we now piss each other off to no end.

The only logical course of action is to sperg back. Never give up.
>>
>>59025445
If you don't needed it, avoid it. All the C++ notions which span beyond the useful level of C with classes and simple generics - I mean the massive kludges of templated type traits and operator overloads called Boost and STL, was a big mistake creating a generation of programmers writing horrible code beyond salvaging.
>>
>>59025546
You sure are putting a lot of words in my mouth.
All you're proving is that Microsoft is fucking stupid, which we all knew already.
>>
>>59025558
Is that a subtle "I just got owned: the post"?
>>
>>59025546
QUALITY CODE
>>
File: 1483915385806.png (602KB, 963x720px) Image search: [Google]
1483915385806.png
602KB, 963x720px
What is the best language for fizzbuzz?
>>
>>59025631
Arabic
الفوران الطنين
>>
>>59025649
that actually looks kinda beautiful
>>
>>59025662
Too bad it sounds like shit.
>>
>>59025663
Behead those who insult islam
>>
>>59025662
It's just a bunch of squiggles.
>>
>>59025675
Behead those who don't install gentoo
>>
>>59025686
That crowd is mutually inclusive I think
>>
File: mpv-shot0003.jpg (262KB, 1920x1080px) Image search: [Google]
mpv-shot0003.jpg
262KB, 1920x1080px
>>59025509

True enough. Some related OC:

https://my.mixtape.moe/nkaiiq.mp4
>>
>>59025663
Achlachlalllal halblakhalar aalallal hakhlalrdal lal halablakhallalalr hakhkhhlaalalalbadlar ahglakhalhalal
>>
>>59025698
photoshop the piano with a C++ book
>>
>>59025685
And DOTS
>>
>>59025702
I wonder what Finnish sounds to them
>>
>>59025715
Fins are mongols

ching chong ching ching
>>
>>59025715
Like mongolian pussy
>>
>/dpt/ turns into /int/
>>
>>59025726
>>59025736
Looks white enough to me
>>
>>59025726
>Fins are mongols

whoa memes

i love memes
>>
File: mcchicken.png (109KB, 700x441px) Image search: [Google]
mcchicken.png
109KB, 700x441px
For me it's the McChicken, the best fast food sandwich.
>>
>>59025698
>https://my.mixtape.moe/nkaiiq.mp4

Down the audio pitch until you tune it to C#, change subs to C# instead of C++.

No shoops needed.
>>
>>59025768
Spotted the trump voter
>>
>>59025784
Duh. Of course Trump voters have good taste compared to Shillary fans
>>
>>59025631

F#
open System

let fizzbuzz start finish =
let inputs = [|"{0}"; "Fizz"; "Buzz"; "FizzBuzz"|]
for i in start..finish do
let f = if (i % 3) = 0 then 1 else 0
let b = if (i % 5) = 0 then 2 else 0
Console.WriteLine(inputs.[f+b], i)

fizzbuzz 1 100
>>
>>59025898
Why do people use memes?
>>
File: mpv-shot0004.jpg (303KB, 1920x1080px) Image search: [Google]
mpv-shot0004.jpg
303KB, 1920x1080px
>>59025780
>C++ vs C#

Well, that was supposed to be the joke. But I guess it needs to be more to the point. The pitch down sounds a little bit weird, and it's only roughly in tune to C#, I'm musically deaf.

https://my.mixtape.moe/jsahxv.mp4
>>
New thread: >>59025931
>>
>>59026010
But the bump limit, you can't do that.
>>
>>59026050
>you can't do that.
He just did it, tho.
>>
>>59026050
It's at the bump limit now.
>>
>>59026113
Good point, I retract my statement.
>>
#include<iostream>
using namespace std;
int main(){
for(int i = 0; i < 100; i++){
if(i % 3 == 0)
cout << "Fizz \n";
if (i % 5 == 0)
cout << "Buzz \n";
if (i % 5 == 0 && i % 3 == 0)
cout << "\t FizzBuzz \n";
}
return 0;
}
>>
>>59025182
>blaming a screwdriver for its inability to slice sausage.
I beg to fucking differ, cunt
I can do anything with a screw driver
I could could motherfucking ramen noodles with a screw driver
Thread posts: 314
Thread images: 27


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