/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: yuno_is_cute.png (1530x1212, 222K)

Other urls found in this thread:

amp-blog.robertelder.org/building-broken-c-parsers/
github.com/FelixPetriconi/AllocatorBuilder
github.com/msys2/msys2/wiki/MSYS2-introduction
twitter.com/SFWRedditImages

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

>What if I'm not entirely a beginner

You are a beginner to lisp. Instead of learning new things, you'll actually have to unlearn some stuff you take for granted in other languages.

>ruby seems neat and simple

It is. Useful, too. It's basically a perfected Perl, a much improved version of the language that isn't write only.

Yeah I don't blame C compilers for fucking up. C is just like javascript in many ways. It's a fucked up language that really should have been designed differently, but there's a good non-shit language hiding deep down dying to get out. To me, C starts becoming good when I take away all the stupid libraries,

The major problem with compiling C is how ridiculously complex the grammar is. It's a context-sensitive grammar that needs unending hacks just to parse correctly. I've never seen someone writing a C header parser just like that and integrating it into their tools. The fact that clang apparently supports this is a game changer.

Why Rust is sooo way bad?

>What are you working on, Jow Forums?
I'm actually in the process of learning Python right now. We are going over variable rules right now. So far, this week I've learned about using the print() & input functions, as well as labeling and inserting functions where needed. We've also gone over the use of \n to drop text down a line, and the use of commas.

My main question here is, now that I'm learning the basics of it all, are there places I can go to, to actually work on things, so I can build my resume/experience/expertise within the field of coding?

> I know I'm still very new at this, but this is actually a lot more fun than I thought it would be.

JavaScript rocks!

Attached: javascript rocks.png (1000x494, 134K)

>should have been designed differently
What's wrong with it?

Hi, i'm a Rust programmer, i have a question.
Which lube i should use for anal gay sex?
Thank you in advance.

I'm making a code editor because all the other ones suck! And so will mine!

>I've never seen someone writing a C header parser just like that and integrating it into their tools. The fact that clang apparently supports this is a game changer.
It be amazing if there were tools for accumulating different values from obnoxious C headers into a database, so that you can easily get whatever offsets and sizes you need to run on a different target.

C is an interesting language in and of itself, but I wish that there was a language specifically designed for easily supporting native code on different targets. Something that made it easy to lay the bytes out exactly like you want them. C inhabits a half portable half architecture dependent purgatory that makes writing high level and low level code more difficult than it has to be.

>mfw reading up on what a legal C may look like
>mfw no face
struct foo boo(void);

struct foo {int i;} boo(void){
struct foo f;
f.i = 0;
return f;
}


int main(void){
return boo().i;
}

amp-blog.robertelder.org/building-broken-c-parsers/

I would say you're a bit early for that but that attitude is great.
Try to find a project you like and read/understand it. Look at the list of issues and see if there's anything you could solve.
A good place to look is github. Also go ask this in a language specific channel. I don't know what python has. But they're likely to have more constructive answers.

>What are you working on, Jow Forums?

I am currently reverse engineering a proprietary and undocumented file format.

Lisp is the most powerful programming language.

Try to consider what design choices led to the other ones sucking, be as specific as possible. Then try to lay out your new design to circumvent the important design flaws.

you have the spirit of freedom

You should be new at programming mate

Is there a language like C but it allows for memory layout optimization? On request if not default.

Optimise it yourself. It's not like it's hard.

When I was first learning Python, I had a lot of fun doing webscraping projects. You might want to look into requests-html. Try playing around with wikipedia data or something.
Another thing would be to try making webapps. Flask is a good choice for that. Good luck!

Attached: Cookie no.jpg (580x581, 47K)

Not sure if this is the right place to ask, but are there any textbooks on (pure) POSIX shell programming? Google results are flooded with bash tutorials and textbooks.

What do you understand under memory layout optimization?

I'm taking a free online course and it's an introduction to programming via Python. All good, but they didn't really cover what pyhton means by this weird module.command() syntax. They just started using that syntax without really explaining it. I know it's in reference to the object orientated nature of the language, where you're calling modules on the objecs properties or something, but still. It's annoying, I don't think I'm going to like Python unfortunately, as much as I'd like to. The whitespaces drive me crazy too.

Freshman here. What’s the difference between Bash and Assembly? I’ve only coded in C.

>What’s the difference between Bash and Assembly?
They have literally nothing to do with each other.

yeah its called C

C++ :)

how

One has #/bin/sh in the beginning of the file, the other does not. I forgot which is which.

How come they're virtually the same then???

It's too big. Even though it's a relatively simple language made out of simple building blocks. And it just keeps getting bigger and bigger with every standard. Some standard features are great such as the nested struct variable assignments. Other features are complete disasters like VLA and the whole Generic and thread stuff from C11. I've pretty much restricted myself to ANSI C and even then I took out the standard library.

There's also the problem of the general undefined-ness of the language. There's syntax and type system complications driven by that. For example, function pointers and data pointers are theoretically incompatible because they might be totally different on certain architectures. Of course, 99% of code out there ignores this and you see dlsym returning void pointers. It's really hard to understand all these pitfalls. Also annoying is the entire type aliasing system that was seemingly imported from FORTRAN because C wanted fast vector operations. It's just asinine when the compiler "optimizes" perfectly good systems code because it aliases types. Instead of having that as the default throughout the entire language, you should be able to declare which pointers do not alias any other pointers. That'd fix this entire issue. Fucking char can alias all pointers but uint8_t can't, even though they're basically the same type in any computer that can connect to the internet. It really tickles my autism.

I wish we could have a C variant that was designed for modern architectures instead. It wouldn't be 100% defined because they'd need room for variability in implementations but I'm sure it would be a nicer language than 80s C and all its legacy crap. For one, let's get rid of the idiotic char type. It's a meaningless, pointless and ambiguous type.

If you actually want to know, look at compiler implementations of languages that aren't inherited from C like forth, lisp, mapl, apl, J, etc. You'll start to see places where another language did something better than C and C did something better than another language.

Okay, thanks user.

C++ is what you are looking for. Someone most likely already implemented an allocator for this, so report back when you found the library.

Thanks for the advice, I'll absolutely check out github! Yeah, I need to learn a bit more before I actually start attempting to write/debug code, but I'd just like to get myself familiar with those websites, so when I am actually ready to begin, I can do so quickly!

>Webscraping projects
Hmm, I haven't heard of this yet, I'll look into it. I also thought about looking into making webapps specifically for Chrome, just as a way to help build something potentially useful. Thanks for the advice, I'll check it out!

wat

>It be amazing if there were tools for accumulating different values from obnoxious C headers into a database, so that you can easily get whatever offsets and sizes you need to run on a different target.

Yeah I agree.

Parsing that shit isn't the actual problem. With enough concentrated autism, you can do it. The problem is actually far more complex than just parsing. The fact is these headers are stateful. They define and undefine shit conditionally. They include other headers conditionally. And only GOD knows what data exists in any given compiler's C preprocessor's environment. There's just NO WAY to get that stuff right.

Want to build a dependency graph of source files? Good luck. Your only chance is getting the compiler to do it. You'll invoke GCC on the code base, have it spit out some idiotic makefile rules and parse that instead. OR you can reduce the problem to a much simpler one: swear on your mother's soul that you'll never use conditional compilation and use simple file inclusion instead. Move all that conditional stuff to the build system instead, let the build system decide which files to include in the build and which files to leave out. That way you _can_ rely on the idea that an include really means "this file includes symbols from another file and therefore depends on it".

You want to figure out what the compiler thinks of types and their sizes on any given platform? Good luck...

>C is an interesting language in and of itself, but I wish that there was a language specifically designed for easily supporting native code on different targets.
>Something that made it easy to lay the bytes out exactly like you want them.
>C inhabits a half portable half architecture dependent purgatory that makes writing high level and low level code more difficult than it has to be.

I completely agree with this.

What the fuck?

What features do you wish C had?

Disjoint unions and multiple return values.

>it's not hard
It's significant work for some applications. I'm not really interested in it from a practical perspective.
It's more that I'd like pgo that gives me a result to test against a typical layout. See how much it mattered.
Know of any tools?
I don't follow. I know that cache line efficiency is a big aspect. But I also imagine there's things I don't know about it.
>C++
>allocator
I found this recently.
github.com/FelixPetriconi/AllocatorBuilder
Pretty cool. If the standard had something like that or this were more complete allocators in C++ wouldn't be terrible.
>allocators do memory layout optimization
We're talking about ordering fields in structs (basically) from the perspective of whole program optimization.

strings, errors, multiple returns

Learn Ruby or Lisp?

>disjoint unions?

You mean union { A | B } where something can be either A or B but not both?

>multiple return values

This should be simple to implement. Just allocate more registers for the other values or put them in the stack. Just like returning a struct really.

auto

I see. Thanks user. Very good post.

Start with Ruby. Really.

>strings

You really don't want this. "Strings" are really just byte arrays with syntax sugar. What you actually want is a rich text processing library.

>errors

I hope you don't mean exceptions.

hard to say without knowing your goals, but lisp if just wanting to learn.

Learn Ruby with SICP.

I also wonder is Rust worth to learn? There is a few jobs with it

can someone give me a run down on how to use MinGW, I installed it yesterday, set the path but I can't get it to work in the command prompt now

did you set the path to the mingw bin directory?

yes i got it working yesterday and i compilled my hello world c program, i just dont know how to get it started again today

You need to do the same thing you did yesterday.

Does the command line just not find the gcc or what message do you get?

i tried the gcc -v command, but i can't remember which directory to use it in

ahhhh im a brainlet

oh it worked in the bin directory, so i assume i just have to navigate there when i want to use it

Install msys2.

>what is PATH

Install msys2 faggot.

is that better than MinGW? i just need a simple compiler so i can started with the C book, it seems like setting this stuff up is harder than the actual language

this or just use GNU

You want to write in C but you're not running a POSIX environment. You need to create a POSIX environment. Install msys2. It will come with the compiler, libraries, an actual real terminal that runs an actual real shell instead of the travesty that is cmd.exe, and even a package manager.

The alternative is installing Linux.

You can add the path of the gcc to the windows user variables so you can always just type gcc in the commandline.

But so you dont always want to compile this way you can just write a batch file that will do this for you.

And then use an Editor like notepad++ that can run macros for you and let it run the batch file.

Or just use the Eclipse c++ version or install visual studio.

Why is a posix environment needed?

It's not.

What would be the benefit or the difference then?

that's my biggest problem with the Ritchie and Kernighan book right now, it just throws you straight into examples of code on page one, with zero introduction on how to compile and run it

Stop asking questions and just install msys2 already. It will do everything the other user is telling you to do manually.

You need it to run the windows port of gcc toolchain because windows can't into POSIX without WSL.
Another option would be using MSVC. Hahhahahaha just don't.
Also msys2 is waaay better and easier to setup than mingw

Does anyone know:

How to compile a win32 application with MinGW, g++ on windows?
Or the flags to do that?

The win32 application need a different entry point that console programs, they need wWinMain instead of just main.
Does anyone know the compiler options to do that?

Im a different user, I just wanted to know because I compiled on windows always just with gcc and didn't how posix were involved.

Are you using an IDE? Consider installing CodeBlocks.

I already have one other language though

You don't actually need to use WinMain, I've always just used main, the parameters you receive from WinMain are pointless. Also, you should never use CodeBlocks it's complete garbage.

>you should never use CodeBlocks it's complete garbage.
what would I use then? notepad?

not him but would you suggest codeblocks or eclipse?

>wWinMain
>w

Welcome to hell. It will only get worse from there. Last time I checked MingW has no support for anything that contains the w character if that character denotes "wide characters" in the context of UTF-16. I don't blame them.

Try to use GetCommandLineW somehow. Know that it will do nothing but unlock even deeper layers of hell for you to descend into.

It's C. POSIX is always involved at some level.

Eh who knows. Maybe the parameters are mangled up if they contain unicode characters. It's not like in reasonable systems where the stuff just gets passed to you untouched as bytes in whatever encoding they happen to be in, which is ASCII or UTF-8 99% of the time.

You would use an msys2 installation. Open any text editor. Save code somewhere. Open a fucking terminal, navigate there and gcc the file. That's it.

Yes, notepad is the only alternative to codeblocks.

it says on the wikipage that installing msys2 will reset all my PATH setting, will it JUST my system if i install it or what

CodeBlocks because using javaids is literally retarded.

Reminder

Attached: 1547883235961.png (500x403, 83K)

>coding like the 50s

It's not going to touch your path. It may or may not inherit your Windows environment variables depending on what you choose. Do you even know what an environment variable is

Reminder

Attached: ur_a_faget_by_thesubtle_d8xvfca-350tumblr.jpg (398x350, 61K)

>For optimal usage, MSYS2 automatically strips your PATH environment variable, essentially only leaving C:\Windows\System32 and few others.
github.com/msys2/msys2/wiki/MSYS2-introduction
and no i have no idea

I feel like all you people are really bad at giving advices to new C progammers.

>>>ruby with sicp
>ruby ever good to learn

I feel like you're a fucking queer. kys

Well okay. That's a pretty badly worded explanation. It's not going to do anything to your system. It will install itself to some secluded directory and will do its own thing there.

I feel like you are trolling. Use linux if you want an optimized environment for c programming.

Him: "how do I compile this hello world C program"
You: "Well just install Linux!"

This is what I'm saying, terrible at advices.

so mysys2 is sort of like gcc but better?

I feel like I gave you excellent advice but you're too incompetent even to swallow it. Install msys2 already faggot. Fucking seriously. How hard can it possibly be? It's a windows program. It's a literal installer. There's no way you can fuck it up and you'll get a micro-linux thing at the end that is not only better at C programming than migrosoft's abandoned tools but will also educate you about linux stuff so that you can be an actual participant in open source development.

LOL install visual studio then. Enjoy the abandoned, absolute garbage C compiler and tools.

>advices

I feel like you are terrible at English. Kill yourself, gook.

msys2 is a thing that makes using gcc, make, git and everything else not be a torturous pain in the ass. It comes with features such as "don't need to navigate to gcc/bin directory in order to use it" out of the box.

Have you installed it already?

sorry like MinGW

It comes with mingw32, mingw64, everything you want.

>be me
>me updating legacy Cobol system
> ~100 of screens, ~300 modules, close to 100 tables
>pre-sql database, not supported (vendor went out of biz in 90s)
>original developers are all dead
> no source control
>ispf
>half in jcl, half in rexx
>few incomplete pieces of documentation on paper in rusty binders, partially eaten by mice or rats
>need code complete/uat complete by March; or i lose my job

>install that
>no install this
>oh install that instead

You understand that the guy just needed to put gcc in his PATH and he was set for life right? It takes 2 seconds. Why are you trying to make him install anything at all?

but i already installed mingw yesterday and i did compile my first hello world c program with it

i wanted to read on in the C book today, and now i can't remember how to get it working again

i can run gcc -v from the bin folder, do i have to put my note++ .c files into the bin folder? it can't find them if my files in a folder on my desktop

and also i apologize for polluting the thread with my stupidity