/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/BurntSushi/ripgrep
github.com/sharkdp/fd
github.com/jwilm/alacritty
github.com/ogham/exa
en.wikipedia.org/wiki/W^X
doc.rust-lang.org/std/primitive.slice.html#method.swap
sdleffler.github.io/RustTypeSystemTuringComplete/
treblig.org/daveG/rust-mand.html
publications.gbdirect.co.uk/c_book/
reddit.com/r/programming/comments/7ryiih/redox_os_crash_challenge/
twitter.com/AnonBabble

sepples is love, sepples is life

Threadly reminder to use #![feature(nll)].

First for Visual Basic

Daily reminder that you should clean your machine from Rust.
Rust can and will reduce your machine performance by reducing the conductivity of all metal part of your machine

What kind of successsful programm has been written in Rust? I can't recall a single one.

Reminder not to use Rust.

Employed Rust programmer here. Why are you guys hating on my hobby?

Threadly reminder that Lisp has lots of cons and all the pros are in their 70s.

Firefox has a lot of components written in Rust
Dropbox, which uses Rust internally
Servo, which is quite successful for a browser engine written from scratch
github.com/BurntSushi/ripgrep is used by VSCode
github.com/sharkdp/fd
github.com/jwilm/alacritty
github.com/ogham/exa
Redox OS is as successful as a hobby OS could be
Also Rust compiler itself is pretty successful

which programming podcasts do you like?

>Redox OS is as successful as a hobby OS could be
>t. bill gates

servo

I don't enjoy writing Rust because I find it to be too limiting.

>Lisp has lots of cons
It's cons all the way down.

So a couple of irrelevant utilities, a buggy toy kernel, programs written by the very shills who fund Rust, the compiler for Rust, and some unspecified parts of Dropbox? Very impressive portfolio for a language that has existed for ~10 years.

it hasn't been stable for a long time

Threadly reminder that if your programming language has not been used to write one of the world's most influential operating systems and set of utilities as soon as it was born, your language is NOT a real systems programming language, and will NEVER be one.

That's still more than 90% of the languages being shilled here have.
>~10 years
Nice revisionism, it has been stable for 2.5 years, before that people were explicitly discouraged from using it for anything serious.

i need to put a website consisting of static html pages (including images, javascript, css etc.) onto wordpress, I have never used wordpress before. What do?

Can you really not swap array elements in Rust?

Only if the array is mutable. Then you must use the standard library function. Yes.

perl CGI scripts

You can safely swap anything you have mutable references to with std::mem:swap.

>That's still more than 90% of the languages being shilled here have.
By which you mean stuff like Idris. Way to go, Rust.

>Nice revisionism
How is it revisionism, you autistic cunt? The fact that the PMS-struck ladyboys can't make their mind up about what they want Rust to be like doesn't change how long it has existed in some form.

>What do?
I'm sure the lovely fellows down the street would know. This is a Rust hate thread.

How would you go about executing a handwritten binary file on Linux? Is it just a matter of adding the ELF header and formatting segments appropriately?

>How would you go about executing a handwritten binary file on Linux?
Use an assembler to compile a dummy executable, then dump your stuff in it.

> stuff like Idris
Also D, Nim, Crystal, Common Lisp, Haskell, Scheme, OCaml, etc.
> doesn't change how long it has existed in some form.
Why stop 10 years ago then? "In some form" can go back to Fortran I, that's a lame argument.

You can try to write a loader that loads the binary and then calls it as a function. I'm not sure how to change the pages permissions to +X tho, but it should be possible, otherwise JITs wouldn't exist.

I want to do it was a learning exercise, that'd kind of defeat the purpose. Otherwise I'd just inline an assembly program in a C program and let gcc take care of everything.

Well, compilers also exist, so clearly user programs can produce executables.

>Why stop 10 years ago then? "In some form" can go back to Fortran I
So Fortran I was Rust? Are you unironically retarded, or just severely confused about matters of identity, Stacy?

>Also D, Nim, Crystal, Common Lisp, Haskell, Scheme, OCaml, etc
Pretty sure more useful software has been written in CL than Rust. As for Nim/D/Crystal etc., give them 10 years, corporate backing, and put them on the right side of Silicon Valley leftist tribalism and then we'll see how they compare. In any case, the fact that you have to compare your toy language to other fledglings speaks for itself.

>Well, compilers also exist, so clearly user programs can produce executables.
No, that's different. A compiler creates the .text section which is loaded by the elf loader into read-only + executable pages, thus allowing the code to be executed but not changed. When you load a binary from a file into memory, you have to explicitly set the page permissions to executable, otherwise, the code won't run. Some OSes have en.wikipedia.org/wiki/W^X , which complicates things somewhat.

>I want to do it was a learning exercise, that'd kind of defeat the purpose
If part of your learning exercise is to learn how the ELF format work, have you considered just googling its specs? Or do you expect someone here to tell you all about it from memory?

>So Fortran I was Rust?
The Rust from 10 years ago has a little to do with the Rust we have now other than the name, so you might as well start with Fortran I.
>Pretty sure more useful software has been written in CL than Rust.
Not in the past 20 years or so.
> As for Nim/D/Crystal etc., give them 10 years
D is 20 years old. I mean actual 20 years since the first stable release, it hasn't taken off, it's practically dead. Nim and Crystal are stillborn.
>In any case, the fact that you have to compare your toy language to other fledglings speaks for itself.
I'm comparing it with the other languages being shilled here, I haven't seen anyone screeching at them for not being used for serious projects because it's a silly way to critique new languages.

I was asking if there was more to it than that, m8. No need to get so frustrated just because you don't understand it yourself.

FUCK YOU YOU LITTLE BITCH I WROTE A BASIC INTERPRETER IN COLLEGE

Firefox is being rewritten in Rust, with major parts of the current version written in Rust.

>filename
=]

>The Rust from 10 years ago has a little to do with the Rust we have now other than the name, so you might as well start with Fortran I.
You from 10 years ago has little to do with the you we have now other than the name, so your identity might as well start with someone else's grandpa. Boy, you are unironically retarded.

>Not in the past 20 years or so.
Fashion changes, but at least people actually used it back then to write real software. All the Rust userbase does is to shill, post fizzbuzz snippets, and argue over what pronouns to use in the docs.

>D is 20 years old. I mean actual 20 years since the first stable release, it hasn't taken off, it's practically dead. Nim and Crystal are stillborn.
As I said:
>As for Nim/D/Crystal etc., give them 10 years, corporate backing, and put them on the right side of Silicon Valley leftist tribalism and then we'll see how they compare.
You can scratch "give them 10 years" in the case of D.

>I'm comparing it with the other languages being shilled here
Again, as I said, that in and of itself is telling.

>I haven't seen anyone screeching at them for not being used for serious projects
I have, at least for D/CL/Haskell which are more heavily shilled.

>it's a silly way to critique new languages
Rust is not a "new language".

>No need to get so frustrated just because you don't understand it yourself.
I have no trouble admitting I don't know its details. I'm just trying to help you not come off as an imbecile next time.

Is there like a style guide or something about how to use C++ as just "C with objects"? I want to start writing a physics simulation/game engine thing, and although I want to do it in C, I think OOP is the way to go for this kind of thing.

data oriented design

>Is there like a style guide or something about how to use C++ as just "C with objects"?
You need a guide to tell you how to avoid C++ features that aren't simple OOP constructs?

>physics simulation/game engine thing
>I think OOP is the way to go for this kind of thing
Not even remotely.

>You from 10 years ago
Programming Languages are just like humans, amirite? By your logic B and BCPL should be included into C's history, and then into C++'s history, because it's basically the evolution of the same language under different names.
>All the Rust userbase does is to shill, post fizzbuzz snippets, and argue over what pronouns to use in the docs.
Keep ignoring the facts, friendo.
>Rust is not a "new language".
Less than 3 years old is pretty much "young".

Haven't heard of that before, wiki page sounds like it's similar to FP?

>You need a guide to tell you how to avoid C++ features that aren't simple OOP constructs?
Yeah maybe not lol
>Not even remotely.
What then?

rust is good, though.

Weekly reminder that Lisp will bring you a lot of cars.

does anyone know any good coding bootcamps in London that are cheap/free?

>By your logic B and BCPL should be included into C's history, and then into C++'s history, because it's basically the evolution of the same language under different names.
No, you absolute fucking mongoloid. By my logic, C and C++ are separate languages, but C++98, C++17 and C++27 are C++, even if C++27 ends up quite different from C++98, for the same reason that you are still you even if you undergo changes over time, and for the same reason that Linux is still Linux even though it has changed over time. Please see a psychiatrist, because you don't seem to have a grip on the concept of identity.

>Keep ignoring the facts
>ignoring
Rust has been used for a couple of irrelevant utilities, a buggy toy kernel, programs written by the very shills who fund Rust, the compiler for Rust, and some unspecified parts of Dropbox. It's basically irrelevant except to its own cult following and financiers. What facts am I ignoring?

>Less than 3 years
10+ years, still incomplete, still irrelevant. It's hilarious to what lengths a mentally ill Rust shill will go to distort reality and defend its toy language.

O U C H

>What then?
Monomorphic functions operating on arrays.

Don't waste your time, all the work is in India where you should be.

image caring this much on an austrian demoscene bbs.

Is Rust the ultimate soyboy language? It is the most loved one by Reddit.

Will probably never dethrone JS just because of the barrier to entry.

I'm just helping it understand why different standards of C++ are C++, while C is not C++. Maybe it will have an easier time emulating human behavior that way.

rust is good. if you disagree you are most like way worse c system programmer than i am. so stuff it nerds.

>tfw working at a company as a programmer for 7 years
>i got hired with a minimum wage coz i had no real working experience and even though in other companies people like me had been paid like 60% more i was fine with it
>tfw 7 years later
>never given a single raise, even though i always do my job, never show up late, took like one sick week during the entire time, got pretty good at the work and know the company stuff related to my work inside and out
>since never got a raise, and the minimum wage kept rising over the years i now get paid less than minimum wage which isn't probably even legal, but i am too big of a pussy to say anything because i am too scared of getting fired
should i just suck it up?
i am afraid that if i ask for a raise i will be just kicked out and they will hire some pajeet for even less who will do much worse work than me, but since my boss is a normie he doesn't understand that programmers aren't all exactly the same even if they use the same prog.
language
i am just so scared of the possibility of ending up as some shitty burger flipper at mcdonalds because there are so many people working in it related shit noways that i wont be able to find another decent job in the field.
But if i stays where i am now i won't be soon even able to afford proper living, since prices and bills and shit go up, while my wage stays the same.
Yes, i realize that i am a loser.

What should i do?

have a brew a listen to some c64/amiga tunes. im done for the night.

I have 0 coding experience and I want a job in tech because if I have to do retail again I may murder someone.

I can't go to India

look for a new job, ask for better comparing offer, move jobs.

You should be looking for a new job for the past 6.5 years.

That makes sense

>That makes sense
I'm actually dead serious. The game engine doesn't care about your OOP abstractions. If it needs to move every active game object based on its current velocity, it cares about positions and velocities. It doesn't care about the entire game object or its class. The same is more or less true for all core engine operations. Game object types start to matter when you're programming gameplay, and for that you don't want to use C++ anyway, and you certainly don't want to use the C++ flavor of OOP.

How long should you stay at a job before you start looking for a new one?

>How long should you stay at a job before you start looking for a new one?
Long enough to have some experience to put on your resume, and for your next employer not to notice that you're job-hopping.

what the fuck have you been doing with your life

>I'm actually dead serious.
I didn't assume you weren't.
So you suggest writing the engine in C and then later scripting stuff in Python or something? Sounds good to me and FFI will be a nice skill for my cv.

>So you suggest writing the engine in C
I'd still write it in C++, mainly so I could overload the basic math operators to work on vectors, and for other neutral features like namespaces.

>and then later scripting stuff in Python or something?
I don't know if Python is good for this or not. It's not widely used for this purpose. Lua is more typical, because it's relatively fast and lightweight. It also has the feature of metatables, so you can implement prototypal inheritance, which is very useful for game objects.

man dont write an engine in c unless you want to implement it from ground up. (blitting, sound, io, memory allocation)

I think you've gotten some good advice.

I also think it depends on what you are trying to accomplish (care to share?). Writing a non-trivial physics engine is, well, non-trivial.

>man dont write an engine in c unless you want to implement it from ground up. (blitting, sound, io, memory allocation)
That's retarded. You'd typically use OpenGL+OpenAL+SDL, which have a C interface, even if you were doing it in C++.

Should I start with K&R C and then learn C89/99/11, or start with C11 and then learn earlier versions if I end up needing them?

Neither.

I'd recommend cmu122 (intro imperative programming).

If you're dead set on choosing between K&R or some subset of other more recent versions of C, I'd say go with K&R IF!!! you are committed to doing all of the exercises.

People will disagree with me.

Warning: K&R style is considered outdated by many.

If you're learning K&R C from the second edition, you're learning ANSI C = C89.

C99 and C11 changes little. This isn't C++.

I think it's possible to make a hentai censoring network. But why would I contribute to the problem I'm trying to solve?

>If you're learning K&R C from the second edition, you're learning ANSI C = C89.
Close but not quite.

I want to implement verlet integration and collisions, starting with rigid body, and the possibility to define custom forces (e.g. lift/downforce from a wing dependent on velocity). I'll just draw triangles with opengl and very simple shading.
I'll look into lua, have a little bit of experience with it but I remember it was kinda weird.

>doesn't let you swap array elements
doc.rust-lang.org/std/primitive.slice.html#method.swap
>cannot write a compile time raytracer
Wrong. Nobody has done it yet.
sdleffler.github.io/RustTypeSystemTuringComplete/
treblig.org/daveG/rust-mand.html

Do you even have any control over cache misses in a language like C#?

C# has value types which can improve cache locality in some data structures, but this isn't C.

Unless you write unsafe C# of course. Then it can pretty much just be C.

read publications.gbdirect.co.uk/c_book/
and just figure out the differences wrt/ newer versions yourself. that book is incredibly lucid.

>Do you even have any control over cache misses
not even C or ASM give you control over cache misses

is rust a cult or not? why are the rustafarians so aggressive and pushy? is the language actually as good as they say.

> reddit.com/r/programming/comments/7ryiih/redox_os_crash_challenge/

HDL do

>Do you even have any control over cache misses in a language like C#?
Doesn't C# let you define plain structs/arrays? In that case, you can lay out your data in an optimal matter and "control" cache misses to the extent they can be controlled.

I can write a loop in C that processes an array and results in a cache miss every single iteration, and I can write a loop in the same way that never does. It's all about data locality. Of course there are some situations where it's unavoidable, but if you're doing something involving data crunching you can massively speed up your C/C++ code by structuring your solution properly.

>is the language actually as good as they say.
The results of the "Redox OS crash challenge" speak for themselves: screeching "muh safety" and "if it compiles, it works" while writing Rust apparently doesn't automatically result in a secure and stable kernel. Not even a toy one.

>is rust a cult
it is
>so aggressive and pushy?
That's how most cults are.
> is the language actually as good as they say
no

also the challenge is a PR stunt to get free QA and buzz.

>plain structs
yes
>arrays
unsure if you can get value type arrays.

>is rust a cult or not?
Not.
>why are the rustafarians so aggressive and pushy?
Everybody is, it's just there are a lot of them.
>is the language actually as good as they say.
Yes.

>is rust a cult or not?
it is
>why are the rustafarians so aggressive and pushy?
That's how most cults are.
>is the language actually as good as they say.
yes

>unsure if you can get value type arrays
Then you're screwed. But I thought being able to do Vector was one of the major C# selling points over Java... why wouldn't you be able to do Vector?

2-3 years, hedging back and forth depending on performance. If you are a quantifiable top-performer, it's okay to move to a bigger company after 2 years. If you're performing well enough to meet expectations, aim for 3 years.

There's also only a handful of totally acceptable reasons to hop, as far as employers are concerned:
1) you're so valuable they don't care (you mostly likely aren't this valuable; very few actually are, despite many believing that they are)
2) you've accomplished everything you can at your level at your current job, and have few to no options of improvement there/have many more options for improvement at a new job/company
3) a switch would give significant material gain (5-10% more money, better benefits, great opportunity to develop skills)
4) you must change jobs because you are moving
Anything else either looks neutral or suspect.

You can. You can do PODStruct[] foo = new PODStruct[n];. foo is a reference to contiguous memory holding all your PODStructs.

Also, always aim for upgrades. A history of totally lateral changes looks bad, especially if you have any kind of negative paperwork/performance than can be dug up.

>trying to use pip in powershell throws an encoding exception
>google it
>"yeah it's common knowledge there's no fix"
>literally can't use pip in windows shell
and yet installable binaries for python 3.7.104 were released for Windows and Mac today but no fucking package for no linux distro, just a shittarball

I can't fucking believe it

If your goal is just to get the damn thing to work, it may be less painful to write in C++.

If your goal is to understand how to write optimal physics engines, which will require much more understanding the high level implementation, you'd probably want to write it in C.

Someone here can comment on optimizing C++, I cannot.

As far as a style guide, I don't think one exists. I think your best bet to learn about best practices is to read source code of existing physics engines (of which there are many!).

But don't dawdle, get going!

>haskell
Is used in dozens of fortune 500's for essential backbone work, you fucking troll.