/dpt/ - Daily Programming Thread

all of you are fucking delusional shitkids

unless you genuinely have a question you need an answer to you should do some programming instead of wasting your time here with meaningless """"""""discussions""""""""

Previous thread:

Other urls found in this thread:

affinelayer.com/pixsrv/
penisinspection.com/penis_score/src/$@
doohickey.info/diddleysquat/$@
penisinspection.com/penis_score/src/),
doohickey.info/diddleysquat/)
youtube.com/watch?v=iVBCBcEANBc
twitter.com/AnonBabble

Reminder not to use shared mutable state.

shit thread. someone make a real one.

First for Swift

>var needCoffee = true;
if (needCoffee) {
console.log('Finding coffee');
} else {
console.log('Keep on keeping on!');
}
WHY IS IT ALWAYS THIS SHITTY EXAMPLE
I HATE COFFEE
MILK + CHOCOLATE IS WAY BETTER FUCK YOU

there are people who are literally here just to waste time and troll people with shitty opinions

Dumb frogposter go back to Sup Forums

give me an app idea Sup Forums

frogless thread:

>I think you come from reddit based on the formatting of your post, therefore your argument is invalid and you need to go back.

I vote the non anime thread.

kys fucking retard

how do you even know what formatting people use on reddit? because YOU are the one who came from reddit

right? fucking redditors, with their careers and real world experience.

yes, that's what a plebbitor would do.
>that reddit formatting
how about you go back?

(You)

"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman

this but with pepes

affinelayer.com/pixsrv/

>Richard Stallman
stopped reading right there. stop posting your leftist garbage.

>>>/reddit/

>can't even link properly
>is a leftist retard
Are we being raided by redditors like you today?
Here, it seems like you're lost

That's a link to Sup Forums, mouth breather

now we have three /dpt/ threads

It's a link to a subreddit. Presumably the subreddit you came from, which is why I posted it to help you find your home

this is the legitimate thread because the old one hit the bump limit and this was posted before the other new thread

>post yfw you made your first decision tree

someone please explain switches better for me?

It jumps to whichever case corresponds to the input, or goes to default if none of them match
switch (2) { // try this code but replacing 2 with different values
case 1: printf("one\n"); break;
case 2: printf("two\n"); break;
default: printf("other\n");
}
// then try again, but see what happens when you remove the "break" keyword

Need some ideas for a new build system. Not one of those bloaty, Yes Man type automated build systems, just a modernization of make.

Current ideas.

>makefile recipe style build script (perhaps not the same syntax)
Conceptually simple and widely understood

>based of builtin scripting language with data structures, first-class functions, lexical scoping, etc.
Because this isn't the 70's and you can afford nice features. Associative arrays would have helped a lot in many of my projects.

>patterns support full regex notation
Because this isn't the 70's... I'm really not lying about that.

>builtin scripting language can be used for dynamic recipe generation
Instead of shit like
PENIS_OBJ = a b c
DOODAD_OBJ = doodad
OBJECTS = $(PENIS_OBJ) $(DOODAD_OBJ)
GET_SRC=wget -q --show-progress --no-use-server-timestamps

# acquire
$(PENIS_OBJ).c:
$(GET_SRC) penisinspection.com/penis_score/src/$@

$(DOODAD_OBJ).c:
$(GET_SRC) doohickey.info/diddleysquat/$@

# compile
$(OBJECTS).o: %.o:%c
$(CC) -o $@ $<


You should be able to write
OBJECTS = {
(a, penisinspection.com/penis_score/src/),
(b, penisinspection.com/penis_score/src/),
(c, penisinspection.com/penis_score/src/),
(doodad, doohickey.info/diddleysquat/)
}

for obj, src in $(OBJECTS) do

$(obj).c:
$(GET_SRC) $(src)/$(obj).c

$(obj).o: $(obj).c
$(CC) -o $(obj).o $(obj).c

end


cont.

Either make it compile into makefiles, or use an already established language that already exists on most systems. Releasing/compiling projects using your build system should not be a pain. Then just build a library of common utilities found in makefiles.
Make things like header dependencies, folder specific settings vs global settings, automatic flags for architecture, etc. really easy to use, because some of that stuff is very arcane in make. Also, preferably try to make it langauge agnostic.

I wonder if "makefile combinators" could be a thing...

>just a modernization of make
What's wrong with Ninja?

so like this?
var lifeStatus = 'poor' ;
switch (Faggot) {
case 'rich fuck': (console.log('oh yeah mad moneyz'));
break;
case 'okay': (console.log('I can live with this fine...'));
break;
case 'poor': (console.log('fuck'));
break;
default:
(console.log('that\'s not a life status you sad fuck'));
break;
}

>var lifeStatus = 'poor' ;
switch (lifeStatus) {
case 'rich fuck': (console.log('oh yeah mad moneyz'));
break;
case 'okay': (console.log('I can live with this fine...'));
break;
case 'poor': (console.log('fuck'));
break;
default:
(console.log('that\'s not a life status you sad fuck'));
break;
}

>builtin scripting language with data structures, first-class functions, lexical scoping, etc.
>not bloaty
>regex
>not the 70's
wew

yes but not all languages can use strings in switch statements so you'd use an enum (enums should have better performance even in languages which support strings in switches)

>use of builtin scripting language to generate recipes dynamically at runtime
Recently, I wrote a build script with make that had to acquire upstream tarballs, unpack them, link the project together, PATCH THE SOURCE DEPENDING UPON THE OS, THE UPSTREAM VERSION, AND THE BUILD ENVIRONMENT, then build the project and install. I capitalized the miserable part. I had to use an external bash script to keep my sanity. The issue also segues into my next point. Patches can't necessary be traced to specific files, so I had to use phony files as a target to keep patches from being applied twice (or just attempt applying twice and squash the error if it was already applied). Of course maintaining that file when new source was retrieved meant patches weren't applied and more scaffolding had to be created to support that monstrosity.

Ideally, what could be done is dynamically create a set of patches that apply given the current OS, build environment, blah blah blah, and generate rules for all of the applicable patches.

>non-PHONY, non-file targets
Some recipes are required by others and don't produce files; like recipes that modify the environment, but you only want to run ONCE. My idea would be to have a dependency file created during runtime that would track target fulfillment and dependencies. It would be equivalent to having a set of recipes creating the phony target files and maintaining their integrity based on changes to their dependencies, but it's already builtin for you.

And a few other thing I shouldn't have to explain
>language agnostic
>basic ability to probe OS and environment for identification so system-specific portability libraries can do their magic
>scripting language can replace shell scripting within makefiles (can call system utilities)

>(console.log('some bullshit'));
For what purpose?

>>based of builtin scripting language with data structures, first-class functions, lexical scoping, etc.
Please no.

Although I appreciate your using of an anime image for this thread, this OP sucks. /dpt/ is all about “"""""""""discussions"""""""".”

>Lisp (or its variant, Scheme)
This is just wrong. There is no language named simply “Lisp.”
Lisp is a family of languages, and have many implementations, including Scheme, and Common Lisp (which is what I think rms is referring to here).
It just triggers me that people call CL just Lisp.

You going to explain yourselves?

Currently, it looks to be just make with a language for generating rules on top of it instead of using make's terribly antiquated recipe generation abilities.

>not meant to be written by hand, but generated
>little to no abstraction ability
If anything it would be the target for the generational scripting language.

>make it compile into makefiles
I was considering that.
This guy suggested Ninja, which is faster. But either way, it generates simple non-abstract rules.


How It compares to other build systems

It is NOT autotools or scons or any of that crap that tries to generate rules for you from source. It will be language agnostic. It is most similar to rake, but ruby is shit and rake doesn't go nearly far enough in some regards, and too far in others. Rake ties the build system into the language, and that will be avoided. It will simply be a DSL for generating makefiles that won't make you want to rip your hair out.

In C++, is there a way to automatically correspond enum values with the strings of their given names?
Right now, I only know to laboriously fill out a function to return a string for each value of each enum class.

>use an already established language that already exists on most systems
Oops, I was going to reply to this in my other response.

Most languages don't support embedding shell commands. But I see a lot of projects that use Lua and LPEG for creating DSLs while exposing Lua's programming features. So it might be Lua-based, which is supported on just about any computer. They recently got the most recent version of Lua to build unmodified on a Turbo C compiler from 1991, so portability isn't an issue.

Go back to /r/The_Douchecanoe

No, C++ has no built-in introspection.

Is there a way to do it in the macros?

rate literally my first javascript code ever
console.log('gotta make some pizza,here are the orders:');
var orderCount = 0;
function takeOrder(topping, crustType) {
console.log('Order: ' + crustType + ' crust topped with ' + topping);
orderCount = orderCount + 1; }
function getSubTotal(itemCount){
return itemCount * 7.5;}
function getTax(){
return getSubTotal(orderCount) * 0.06;
}
function getTotal(){
return getSubTotal(orderCount) + getTax();
}

takeOrder('bacon', 'thin');
takeOrder('pepperoni', 'regular');
takeOrder('pesto', 'thin');

console.log('total cost is: $' + getSubTotal(orderCount));
console.log('total cost with taxes is $' + getTotal());

I'm sorry but where can I input my code?notepad?cmd?

What programming language?

javascript or HTML

Fuck off, frog shitter

You can type it in notepad and save it to your computer with .html or .htm file extension and then open it with your browser. You can also save pure Javascript in a .js file, but you can't run it directly, you have to include it in a html file with the script tag.

Yes but it would be ugly hacky shit.

You'd have to implement a class enclosing en enum type, constructed with a variable number of strings, methods to convert from string to integer and back again. Not that convenient without language support.

You edit code in a text editor. Notepad is an example of one, but it is of rather poor quality compared to other editors on the market. If you are on Windows and do not want to spend much time learning a decent editor, Notepad++ is a good beginner's editor with support for a number of commonly desired text editor features.

First for OCaml.

I mean executing it and showing on a console.log
editing it I can do it on a notepad for sure,but I want to input and execute that code to see if it works or if a error comes up

>Most languages don't support embedding shell commands.
Every language worth its salt has some way to achieve this. And you probably don't want this directly if you plan to build anything on windows.
Lua would be fine, Python/Ruby would be fine.
This interests me and I might try to make something like this in Haskell as a meme

No, you don't. That's even worse than what I had in mind. Just use X-macros.

#define VALUES \
X(thing1), \
X(thing2)

#define X(x) x
enum { VALUES };

#undef X
#define X(x) #x
const char *str[] = { VALUES };

>stopped at the end
So you made it to the end.

3:30

youtube.com/watch?v=iVBCBcEANBc

To the end relative to the usual reading order? Yes. But I didn't start from left to right.

see