
SyntaxDB – Quickly look up syntax for programming languages - sidcool
https://syntaxdb.com/
======
stepvhen
I would suggest using "learn x in y minutes" [1] if you need to lookup syntax
for something. It doesn't feature the "for loop in java" search function, but
it has more languages than this tool, as well as tools like vim, git, tmux,
with many files having multiple natural language translations. It is also
community driven, so if there is something missing it is only a pull-request
away.

[1] [https://learnxinyminutes.com/](https://learnxinyminutes.com/)

~~~
pc2g4d
Cool site, but are there no English translations? Could be good for my (non-
computer) language learning, though!

~~~
jorams
Just click the language name. All guides are in English, with translations to
other languages available in addition to that.

------
mywittyname
Right now, this isn't really any better than looking at an individual
language's site for syntax, this just offers a common user interface. For
example, the site has no idea what a list comprehension is, yet that's a
fundamental component of python.

I think a transpiler would be absolutely awesome -- even if it only works on
curated code samples on the site. Something that shows how a piece of code can
be expressed in many different languages. This would be extremely useful for
things like Regular Expressions (also, no results found for regular
expressions on the site), which are in just about every language, but are
treated very differently.

Personally, I think that's your killer idea. It will be damn hard to do, but
if you can make it work, I think you'll end up with a lot of visitors. Knowing
the language idioms is key to understanding a language.

~~~
thenipper
Would a transpiler kind of be like rosetta code?

~~~
mywittyname
Yeah, I mean I use that word because it conveys the result I'd like to see.

A syntax database is not terribly useful. A concept database is where the real
value is. The idea is that a language is much more than just raw syntax. C++,
Python, and awk are all so fundamentally different that explaining the
differences in terms of syntax is ultimately worthless.

Even something like "array in C++" vs. "arrays in python" is not very valuable
because they really mean totally different things. There's a lot of unknown-
unknowns for a Python programmer whose never seen C++ code in their life. They
would never think that arrays are fixed length and accept only one data type
because lists in Python have neither limitation, likewise, a C++ programmer
might be looking something to that behaves like std::vector not understanding
that Python lists are perfectly appropriate.

It would be perfectly acceptable to have people write the "same" (ideally,
non-trivial) code in different languages and link them together. In fact,
that's probably what they should seek to do.

~~~
thenipper
You might not see this but I totally get what you mean. It'd be interesting to
see something that broke programming down to that sort of core level. I'm sure
it exists somewhere in some CS lab right?

------
anthnguyen94
Hey HN, I'm the developer behind SyntaxDB. This feedback is good and I
encourage people to keep it coming!

A lot of responses will be about "there's no result for x". You're right,
there isn't nearly as much content on the site as I'd like there to be!

The content is actually hand written, and as of right now focuses on the very
basic programming fundamentals common across all of the languages. The plan is
to triple the amount of content in the database (adding DS, special classes,
parsing, etc.), and eventually open up the database to outside contributions.

Additional languages are coming too!

~~~
Etheryte
How do you plan to compare and compete with other projects such as Stack
Overflow documentation (currently in closed beta iirc) which, as far as I can
see, offers the same functionality, but a larger user base?

~~~
anthnguyen94
SO documentation looks very cool actually, and it'll be interesting to see how
it turns out. I'm all for documentation being easier across all services, and
I care a lot more about having this problem solved rather than pushing
SyntaxDB to compete with existing services.

With that being said, I think the current integrations and the ones planned
ahead will continue to make SyntaxDB a good option, even if other sites try a
similar idea.

------
adontz
Idea is good, but search does not take into account language specifics. I mean
same keywords do not mean same things in different languages. For instance,
for and foreach are one and the same in Python (actually there is no for, just
foreach named for), so if look for Python version of C#'s foreach I find
nothing.

~~~
anthnguyen94
I actually have something in place which handles some cases of differences in
keywords across languages. For example, searching for "dictionary in java"
would return a HashMap.

I guess I didn't account the specific "foreach" keyword with C# (I have it as
"for each"), good catch!

------
robbles
A while back, there was a service on the front page that was a combination of
search engine for code, static analysis, and git repository browser. The
initial implementation was for Golang only.

Does anybody remember what that project was? Does it still exist?

Slightly OT, sorry. This project just reminded me of it.

~~~
nepalisaathi
Do you mean Sourcegraph? [https://sourcegraph.com/](https://sourcegraph.com/)

~~~
sqs
Sourcegraph CEO here. Yep, Sourcegraph
([https://sourcegraph.com](https://sourcegraph.com)) is a fast, global,
semantic code search & cross-reference engine. It helps developers discover
and understand code. It fits the description above. :)

We support Go and Java now. More languages are coming soon (JavaScript,
Python, etc.).

SyntaxDB is super cool, BTW.

~~~
robbles
Awesome - looking forward to trying it out again!

Definitely would use Sourcegraph with Python support.

------
SmellTheGlove
This is a very good idea. As others have said, and the creator acknowledged,
there isn't a lot of content yet. Community contribution would be very cool.

I'm not sure if I have a good idea here or not, but focusing on older and/or
more esoteric languages is a potential niche. For instance, and these are real
examples, maybe I've inherited some SAS code with a nasty DATA step and I
don't really know how a MERGE works. Or COBOL. I always have ridiculous COBOL
things to google.

As someone else pointed out, though, I think you need some cross-search
between idioms. I might not know what a SAS DATA MERGE is, but if I look for a
SAS join, tell me how to do it in PROC SQL or the DATA step.

Keep going, I think this is very cool.

------
quaffapint
I think this would be great to open up to the community to maintain. Maybe you
approve it initially, and eventually come up with a system for community
approval.

~~~
alexkavon
Agreed. A moderation approach and applied merit could foster a healthy
community as well as innovation with this.

~~~
anthnguyen94
That's the plan! Just a way to allow community contributions, provide
incentives while maintaining the quality of content.

------
bbeausej
Very good idea, though usually a simple google search will provide good
information. Slack integration is actually pretty cool!

I wish it was more complete though!

"No results found for bash if"
[https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=...](https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=bash+if)

------
jkoudys
I like this site, but i'm uncomfortable with it for the same reason w3schools
is such a steaming pile. It can be more dangerous to project authority but not
actually be accurate.

I don't have to look for long to find inaccurate statements, e.g. the page
that describes "for of" in ecma states that order is not guaranteed, when the
order of an `of` is however the iterator is defined for that collection. e.g.
`for (const a of (function*() { yield 1; yield 2; })())` is certainly going to
have an order. I think they were just confusing it with for in.

------
fish2000
Good start but -- some C++ stuff is wrong, e.g. in the bit on friend
functions, a member function prototype is written with an empty block instead
of a terminal ";". Subtle, but you know. Also, more subjectively, std::string
is described as immutable, but with no further discussion about what that
means or how that might work.

Just sayin. Frankly I like how it's not Wikipedianishly drowning in citations
and/or demands for same -- but how does it get updated? I immediately tried to
expand on those two issues I mentioned but there was no sort of UX recourse
for my pedantic urges (FWIW)

~~~
anthnguyen94
Thanks for pointing that out! As of right now, it all gets updated manually
(there's an internal CMS I built and use). As of right now, when people point
out corrections they do so via feedback form, and I update accordingly (if I
can verify it). Not the greatest but it's what's in place for the time being.

It'll later be open for others to provide new concepts and corrections.

------
Gys
Ideally to me this is part of the editor. I use Visual Code + Go.

I think there is still a lot of improvement possible for the help that the
editor (plus tools) can offer. Much more (and more intelligent !) help and
info to be shown while I type or move around in code. At the very least
instantly show parameter types plus full docs on every function my cursor is
on. Visual Code does a good job with the Go plugin but it could be faster. And
there is only so much a plugin can do.

If AI is really the future of coding then it least at some point it should be
more helpful before it takes over...

~~~
smhenderson
On of the items on his "Future" list is creating plugins for editors.

[https://syntaxdb.com/about](https://syntaxdb.com/about)

------
theseoafs
Three rather simple queries I ran that turned up with nothing:

    
    
        do notation in haskell
        with python
        function pointer c

~~~
anthnguyen94
The site doesn't actually support Haskell or Obj-C atm (will in the future).

I also need to improve the search engine to handle queries with additional
words that might give a null result, as well as words like "foreach" (that has
to do with the database). This will be fixed very soon.

It is bad that there are missing concepts, and I'm fully aware that this isn't
even close to complete. The goal in the future is to have as few null result
queries as possible. I actually make note of queries that don't provide
results so I'm glad everyone's making these known, it'll only make the
database better in the future!

~~~
theseoafs
Talking about C, not objective C. :)

~~~
anthnguyen94
Was addressing the other commenter too! Hehe

------
kevlar1818
"No results found for list comprehension in python"

[https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=...](https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=list+comprehension+in+python)

------
daenney
Is there any way to suggest improvements, or heck, raise PRs, instead of using
the feedback button?

For example, the for in Python should include an example using enumerate too
which I'd be happy to add and contain some additional docs on xrange vs range
in Python 2 vs Python 3.

------
aneil
I used the pattern suggested, but came up with no useful results after 3
tries:

* "channels in go" (no result)

* "mutex"(no result)

* "generator in python" (returned a page describing the Python programming language)

------
aardvark179
It's not a bad idea but it seems a bit sparse at the moment even in the
languages it does support. Search for lambda does give anything about Java 8's
lambda syntax, and search for annotation returns nothing at all.

------
taf2
[https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=...](https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=Rust)

no results?

~~~
marxidad
Right now it's only Java, C, C++, C#, Python, Ruby, JavaScript, Swift, and Go.

~~~
kherkeladze
Sure

[http://imgur.com/0cJTqz3](http://imgur.com/0cJTqz3)

------
blairanderson
Pretty darn cool!

Feature suggestions:

\- include the code-highlighted syntax block in the typeahead suggestions. \-
When i hit 'enter' on a typeahead suggestion, send the user to the page
instead of just filling the input.

------
dendory
I made [https://dendory.net/coding](https://dendory.net/coding) a while back
as a cheatsheet of syntax between languages.

------
ruffrey
I'd love to see syntax examples for objective-block usage. I swear I go to
fuckingblocksyntax.com every few days, but it still doesn't have any examples.

------
geon
I have used [http://fuckingblocksyntax.com](http://fuckingblocksyntax.com) a
lot.

------
ndesaulniers
there's no pass by reference in C! [https://syntaxdb.com/ref/c/pass-by-
ref](https://syntaxdb.com/ref/c/pass-by-ref)

I'd recommend const pointers, maybe function pointers, arrays of function
pointers.

For JS, I'd recommend instanceof.

------
k2xl
The one language that I always have to look up how to do a for loop for is
bash.

"for loop in bash" no results :-(

~~~
anthnguyen94
So many people (including myself at times LOL) have asked for Bash. It'll be
on there soon enough!

------
zwilliamson
Bash is a go to scripting language for most. It would be great to see it on
here.

------
jeroneemou
It does not work ...
[https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=...](https://syntaxdb.com/reference/search?utf8=%E2%9C%93&search=php+foreach)

~~~
brazzledazzle
php isn't in the list of languages it supports.

~~~
jv22222
I noticed that and was wondering why php is not supported :/

------
quantum_nerd
this is potentially an amazing idea, especially for those of us who work in
polyglot systems. However, a search as simple as "queue in java" returns no
result?

------
davydka
I tried typing elixir and erlang. No results.

------
divyekapoor
Bash... sorely missing and sorely needed. :)

------
taesu
failed finding list comprehension in Python

------
apatap
What is the business model behind this offering?

~~~
Retra
What is the business model behind your question?

~~~
apatap
Isn't it expensive to host the DB servers?

